Given an array of bytes representing text in some unknown encoding (usually UTF-8 or ISO-8859-1, but not necessarily so), what is the best way to obtain a guess for the most likely encoding used (in Java)?
Worth noting:
No additional meta-data is available. The byte array is literally the only available input.
The detection algorithm ...
I need to get access to EL functionality in a Servlet Filter, but... that means I am not within the FacesServlet lifecycle.
Thus, I need to instantiate an ELContext. I do not want to go down the road of instantiating a FacesContext, since that may cause issues when the application does forward to FacesServlet.
Suggestions? Thanks!
...
I wrote a Java application that reads and sends SMS messages from a USB GSM modem. I'm using SMSLib (which uses JavaCommAPI), and it runs on Windows. I need to pass in the COM PORT, that the modem appears to be connected to.
So far, I've been looking up the COM PORT manually using the Windows Device Manager, and write it into a propert...
I am modeling a small State diagram. Each "state class needs to have its transition class. How do I ensure the developers make a transition class for each state class? The state and the transition both are subclassed from their corresponding Abstract classes.
EDIT: I was working on the Head first Design Patterns and I tried to make my o...
Normally (ie. not concurrently), putAll() cannot be more efficient than using lot's of calls to put(), even assuming that you exclude the cost of building the other Map that you pass to putAll(). That's because putAll() will need to iterate the passed Map's elements, as well as running through the algorithm for adding each key value pair...
I see a similar question in Problems while saving a pre-persisted object in Google App Engine (Java), and indeed I was not calling close() on my persistence manager. However, I am now calling close, but my object update is not being persisted. Specifically, I want to remove an element from a Set, and save that smaller set. Here is the...
I started a new job recently. I've been a Java & XML Web Developer for two years. The new place I'm at has several large web applications, but none of them deploy to my local JBOSS server because some genius decided to create a Java Projects instead of a Dynamic Web Project. I tried following the steps to convert the project but that cre...
Why byte b = (byte) 0xFF is equal to integer -1?
Ex:
int value = byte b = (byte) 0xFF;
System.out.println(value);
it will print -1?
...
My HTML contains tags of the following form:
<div class="author"><a href="/user/1" title="View user profile.">Apple</a> - October 22, 2009 - 01:07</div>
I'd like to extract the date, "October 22, 2009 - 01:07" in this example, from each tag
I've implemented javax.swing.text.html.HTMLEditorKit.ParserCallback as follows:
class HTMLP...
Hi
As per java, instance method resolution is based on runtime types of the arguments.
But while resolving instance variable it uses different approach as shown below.
Output of program is ..
Child
Parent
ParentNonStatic
Here First output is based on runtime types of the argument but third output is not.
can any on...
When Maven builds a JAR file, it places the module's POM file inside (seemingly in the directory <groupid>/<artifactid>).
When I build a JAR file from Ant to be deployed via the Maven Ant tasks, is the presence of this POM file (the one inside the JAR) important? It doesn't seem to be, but I just wanted to be sure that it is not being ...
Simply stated, I am trying to make a game I am working on full-screen.
I have the following code I am trying to use:
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gs = ge.getDefaultScreenDevice();
if(!gs.isFullScreenSupported()) {
System.out.println("full-screen not supported");
}
Frame...
So I have a webview I'd like to display as a dialog. I'd like the webview to fill the entire screen, except for a button below it that I'd like to stay at the bottom of the dialog regardless of how much content is in the webview. Currently my webview fills up the dialog just enough to push the button off the screen. I'm sure this is some...
Anytime I have to re-import my projects into Eclipse (if I reinstalled Eclipse, or changed the location of the projects), almost all of my overridden methods are not formatted correctly, causing the error 'The method ?????????? must override a superclass method'.
It may be noteworthy to mention this is with Android projects - for whatev...
Hi,
I have written within a JSP page to have Thread.sleep() for more than 1 hour. The JSP is deploayed on WebLogic server 9.2. I am trying to check the browser timeout and page cannot be displayed error.
As per the below documentation, the default timeout for IE6 is 60 seconds. However, I was testing the above JSP and did not get any t...
I need to read meta data from .img, .osc and .mccd files.
Can you anyone recommend any libraries or provide any pointers as to how I would go about doing this. Eventually I need to put that meta-data into an XML file so it can be harvested by a repository.
...
If I override either method on a class, it must make sure that if A.equals(B) = true then (A.hashCode() == B.hashCode) must also be true.
Can someone show me a simple example where if this is violated, it'll cause a problem? I think it has something to do with if you use that class as the type of keys to Hashmap?
...
Hi... I'm here again with a docs question.
At my university, when using Eclipse, when placing the cursor
over a Java API method name (for example: .size() ), I get
very nice documentation about it.
Here at home I get
Note: This element neither has attached source nor attached Javadoc
and hence no information could be found.
Any qu...
Hi.
Does anyone know, how to, in iText, add multiline text in bounding box (with coordinates specified).
I tried
cb.showTextAligned(PdfContentByte.ALIGN_LEFT, text, bounds.getLeft(), TOTAL_HEIGHT-bounds.getTop(), 0);
But it does not support newlines.
I also tried
PdfContentByte cb = writer.getDirectContent();
cb.moveText(300,40...
What is the commonly accepted method for converting arbitrary objects to and from their String representations, assuming that the exact class of the object is known ? In other words, I need to implement some methods similar to the following:
public interface Converter {
/**
* Convert this object to its String representation.
...