Is there an appender that I can use that will get me daily rolling, compression and max files? I can get daily rolling file with compression using apache-log4j-extras with this configuration: But I can’t specify MaxBackupIndex as in org.apache.log4j.RollingFileAppender (note the slight namespace differe…
Java FTP 550 error
I’m getting this error (550 the filename, directory name, or volume label syntax is incorrect. ) I think the url is correct (obviously not though). Any thoughts? Here is the url: Here is the invocation method: ftp class: Answer If the FTP server is running Windows, the ‘*’ characters are the…
java.lang.OutOfMemoryError: Java heap space in allocating array size
I am doing very small program in java using Eclipse Kepler IDE. I am allocating the size of the array at run time using the following statement. so as per my knowledge the java program runs with some of its own heap space like 32 MB. And for my program i think this space is enough. I just given the
How to get host name with port from a http or https request
I have two applications deployed in a JBoss container (same unix box). If I receive a request from app1, I need to send a corresponding request for app2. An Example: If app1 requests: http://example.com/context?param1=123, then I need to extract http://example.com/, so that I can send the request for the seco…
How can I draw with Graphics2D on the JGraphX graph?
How can I can draw with Graphics2D on the JGraphX graph? I tried something like this: Answer First, graph.refresh(); will erase the dranw line since it will re-render all the graph on the graphics of the component. Secondly, don’t forget to call the draw function in the ADT Thread Other than that, it sh…
Saving byte array using SharedPreferences
So I have a byte [] array which I have created in my android app. I want to use SharedPreferences from android to store it and retrieve it back again when I start my app. How can I do that ? Answer You could try to save it has a String: Storing the array: Retrieving the array:
Hibernate SaveOrUpdate – multiple workthreads
While I have been able to find information on how Hibernate’s transaction work, so the database doesn’t corrupted, it has been harder to understand how Hibernate treats an object which is shared between threads, and each thread tries to save it to the database. This is my theoretical question: 1) …
Atmosphere responses, broadcasts do not call javascript onMessage handler
I’m working with atmosphere trying to get the simple base implementation using atmosphere 2.0.3 tomcat 7.0.42 running locally in my eclipse environment (also connecting from external machine to see traffic with wireshark). The problem I am experiencing is no matter what transport I use, websocket, sse, …
Delete anything between “<” and “>” in a String
I have try restString = restString.replaceAll(“\<.*\>”, “”); and restString = restString.replaceAll(“\<[^(\>)]*\>”, “”);. Both seems don’t work. I don’t know if I could represent the meaning in the regular expression…
Java Fastest way to read through text file with 2 million lines
Currently I am using scanner/filereader and using while hasnextline. I think this method is not highly efficient. Is there any other method to read file with the similar functionality of this? Answer You will find that BufferedReader.readLine() is as fast as you need: you can read millions of lines a second w…