java

How to unblock a thread blocked on ServerSocket.accept()?

I have a server thread with this code: public void run() { try { ServerSocket server; EneaLog.printLog("Server is running."); server = new ServerSocket(this.portnumber); while (true) { new EneaServerConnection(server.accept(), this.project,stopped).start(); if (stopped) { ...

How can you handle invalid enum types using JAXB?

We are using JAXB to handle our wsdl validation. In the wsdl we have an enumeration like so: <xs:simpleType name="myEnum"> <xs:annotation> <xs:documentation>The enums which matter.</xs:documentation> </xs:annotation> <xs:restriction base="xs:string"> <xs:enumeration value="MYENUM_1"> <xs:annotatio...

Java SortedSet + Comparator, consistency with equals() question

I'd like to have a SortedSet of Collections (Sets themselves, in this case, but not necessarily in general), that sorts by Collection size. This seems to violate the proscription to have the Comparator be consistent with equals() - i.e., two collections may be unequal (by having different elements), but compare to the same value (becaus...

Compare the content of 2 text files in java language

please help me to make the code package utils; import java.io.*; class compare { public static void main(String args[]) throws IOException { FileInputStream file1 = new InputStream(args[0]); FileInputStream file2 = new InputStream(args[1]); try { if(args.length != 2) throw (new RuntimeException("Usage : java compare <filetor...

Get the correct local IP adress from java applet

I would like to determine the local IP adress from my java applet. The problem is when there are several IP adresses on the same machine, which has LAN and internet connections (palm, VMWare...). Here is my test : public static void main(String[] args) { try { String hostName = InetAddress.getLocalHost().getHostName(...

How do I get my generic class to require its parameters to extend/implement multiple classes?

I'm looking for the correct syntax for the following: public class Foobar<K extends SomeJavaAPIClass and implements Cloneable>{ So that I can have Foobars of 'K', where K is a generic subclass of SomeJavaAPIClass and where K has it's own clone() method I've tried <K extends SomeJavaAPIClass, implements Cloneable> with no luck, along...

Convert a string to XML input stream in java

Hi, I'm trying to generate a PDF document using FOP and Java. I receive the XML as a string and not as a file. How can I convert this XML string to an XML input stream so that I can call xslfoTransformer.transform(source, res); where source is my XML string as an Input stream. Please provide your suggestions. ...

Timeout when ssh command is executed from my Java program

I have a Java program which runs in Tomcat and which needs to execute several ssh and scp commands, as well as a few simple commands such as ls on the local machine. I am having trouble with my current approach in that I am getting a time out every time I execute an ssh command. I can run the ssh command on the command line with no pro...

How can I see what exactly contains a proprieties variable?

I'm pretty new to Java, so don't kill me :) FileInputStream files = new FileInputStream(path); Properties prop = new Properties(); try { props.load(fis); ..... Let's say the files is: Mary goes to school, or, not. How can I see how the information was stocked inside the prop variable. I understand that...

HTML Multiple form - Refresh Problem

I have got two forms in a page. The second form has got a file upload input component along with other controls. My requirement is to submit the second form with the file and refresh only that form without refreshing the other form. If it was only normal components, I could have done this easily in Ajax. But when the form is having a fil...

question deleted

question deleted ...

How do I set a float without using an OGNL converter?

I have a class that looks like this: public class Foobar { private float value; public void setValue(float value) { this.value = value; } } I then have a webpage (Struts2) that passed in a variable foobar.value. <input type="text" name="foobar.value" value="123.456"> I then get this error: ognl.MethodFailedException...

Java: How to add a shortkey to a component

Hello, In the JMenuItem-class you can add a shortkey. Is this possible to add this shortkey to a component or the application without using a JMenu. Martijn ...

Java does not have a listDirectories/listFiles method, any native library?

Possible Duplicate: How to retrieve a list of directories QUICKLY in Java? Java does not have a listDirectories/listFiles method, in order to find out your set of directories or files, you have to iterate through each one and call isDirectory. This proves to be a huge performance problem for us in the unix platform. Is there a n...

How to read a bin file to a byte array?

I have a bin file that I need to convert to a byte array. Can anyone tell me how to do this? Here is what I have so far: File f = new File("notification.bin"); is = new FileInputStream(f); long length = f.length(); /*if (length > Integer.MAX_VALUE) { // File is too large }*/ // Create the byte array to hold the data byte[] byt...

Do they have the equivalent of C# static classes in Java?

Do they have the equivalent of C# static classes in Java? I want to create a C# static class but in Java, how do I do it? Thanks for the help. EDIT: Thanks for the help guys. :) ...

How do a send an HTTPS request through a proxy in Java?

I am trying to send a request to a server using the HttpsUrlConnection class. The server has certificate issues, so I set up a TrustManager that trusts everything, as well as a hostname verifier that is equally lenient. This manager works just fine when I make my request directly, but it doesn't seem to be used at all when I send the r...

Set Combinatorics Algorithm in Java

I have a data set with attributes like this: Marital_status = {M,S,W,D} IsBlind = {Y,N} IsDisabled = {Y,N} IsVetaran = {Y,N} etc. There are about 200 such variables. I need an algorithm to generate combinations of the attributes, with one value at a time. In other words, my first combination would be: Marital_status = M, IsBlind = ...

URL parameter encoding/receiving problem

hi all, I use the below code to send data to a servlet: When encoding = "UTF-8" or "GBK", the data is received correctly. But when encoding = "UTF-16", The receiver receives null. WHY?? The Sender: URL url = new URL(notifyURL); HttpURLConnection connection = (HttpURLConnection)url.openConnection(); connection.setDoOutput(true); ...

Problem with nullable types in .NET WS client

Hi, I've WebService written in Java that has method @WebMethod public void createUser(Long id, String name) { } Now I want to use this method in .NET client. I think I should be able to use this method with nullable long but I can't. Is there any annotation or maybe some other way to force .NET use nullable types? I think that ...