I'm trying to read input from the terminal. For this, I'm using a BufferedReader. Here's my code.
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String[] args;
do {
System.out.println(stateManager.currentState().toString());
System.out.print("> ");
args = reader.readLine().split(" ");
// us...
Exact Duplicate:
combine paths in java
I would like to know if there is such a method in Java. Take this snippet as example :
// this will output a/b
System.out.println(path_join("a","b"));
// a/b
System.out.println(path_join("a","/b");
...
I am looking for a utility method or constant in Java that will return me the bytes that correspond to the appropriate byte order mark for an encoding, but I can't seem to find one. Is there one? I really would like to do something like:
byte[] bom = Charset.forName( CharEncoding.UTF8 ).getByteOrderMark();
Where CharEncoding comes fr...
We are running an web application that is using Java 64bit 5 gigs of -Xmx of maximum heap size. We have no control over the java code. We can only tweak configuration parameters. The situation that we are facing is that the java processes after it takes the full heap allocated at start up, it starts acting very responding very slow to...
Using JSTL's forEach tag, is it possible to iterate in reverse order?
...
I'm trying to create a simple web project using Tomcat in Java.
In the web.xml file, I point to a servlet that I want to be run when someone goes to http://localhost:8080/MyProject , so I used / as the URL pattern. That worked, however it has the disadvantage that all links to html and javascript files are being passed on to the main se...
I've got a Grails application that does a fairly decent amount of domain object creation and destruction, and it seems to run out of PermGen space at a very, very rapid rate. I've done the usual tweaks (bumped PermGen to 256M, enabled class GC, etc.), but no dice.
Would anyone care to recommend some (and hopefully free or very low-cost...
I'm using this code:
for (final String code : Locale.getISOCountries())
{
//stuff here
}
But on compile I get this error:
[ERROR] Line 21: No source code is available for type java.util.Locale; did you forget to inherit a required module?
And then a stack trace of compiler errors.
I'm doing both of these import...
Other than Locale.getISOCountries() that is, because I'm already getting some strange errors with that. What else is the best way to get the 2-letter country codes as well as the full country name?
...
Hello,
I am using Ganymede (Eclipse 3.4) to do some Java EE based web development targeting a JBoss 4.2 application server.
I have always liked Eclipse very much for a Java editor. The thing is, for Java EE is not as useful as one might think. It's buggy, deployment and debugging is very slow, and you have to re-deploy your Java EE ap...
I am storing a list of classes through (Classname.class) and would like to instantiate one? Is this possible?
newInstance seems to the method I am after but it doesn't support a constructor?
...
On the program I'm writing I have a class RestrictedUser and class User that is derived from RestrictedUser. I'm trying to hide the User specific methods by casting to RestrictedUser but when I do the casting the User methods are still available. Also when I run the debugger the type of the variable comes up as User.
RestrictedUser rest...
Does anybody know of anything that exists in the Java world to map midi note numbers to specific note names and octave numbers. For example, see the reference table:
http://www.harmony-central.com/MIDI/Doc/table2.html
I want to map a midi note number 60 to it's corresponding note name (MiddleC) in octave 4. I could write a utility cl...
Hi,
I have a c# winapp that calls a java app by tcp and sends everything back by tcp to the c#.
The reason why I'm using java is because I received a java api. So I wrote a small java app that calls that api and get all the data I need.
So I was wondering if there is another solution for this. Because it's going slow, especially with ...
We're running a fairly complex app as a portlet on Websphere Portal Server 5.1 on AIX using IBM JDK 1.4.2. On our production system I can see a strange behaviour in the verbose GC logs. After a period of normal behaviour the system can start rapidly allocating larger and larger blocks. The system starts to spend > 1000 ms to complete eac...
hi,i have byte array stored by both hexadecimal and decimal value,i want to search for hexadecimal 1 i'e SOH in the how can i do this in java,plz give a sample code.
int SOH=0X01;
if(SOH==1)
is showing true.is it correct or not.
thaks in advance.
...
I'm creating a Java socket in Javascript, sending an HTTP request and receiving a response correctly but I seem to be unable to detect an EOF or the server closing the socket at the end. What am I doing wrong? The problem is we never exit the outermost while loop - the server stops transmitting and (presumably) closes its end of the conn...
I have seen several places that "Class.getClassLoader() returns the ClassLoader used to load that particular class", and therefore, I am stumped by the results of the following example:
package test;
import java.lang.*;
public class ClassLoaders {
public static void main(String[] args) throws java.lang.ClassNotFoundException{
...
What happens when you concurrently open two (or more) FileOutputStreams on the same file?
The Java API says this:
Some platforms, in particular, allow a file to be opened for writing by only one FileOutputStream (or other file-writing object) at a time.
I'm guessing Windows isn't such a platform, because I have two threads that re...
I have a project which will be made up mostly of Java Servlets, JSP/Html pages, and some regular javascript. However, there are some screens which will be too complex to do in just javascript, so I will want to use GWT for that.
Is it possible to do this, so there are multiple EntryPoint classes in the same project? Then, depending on w...