As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, …
Tag: java
How to copy a java.util.List into another java.util.List
I have a List<SomeBean> that is populated from a Web Service. I want to copy/clone the contents of that list into an empty list of the same type. A Google search for copying a list suggested me to use Collections.copy() method. In all the examples I saw, the destination list was supposed to contain the …
what are the benefits of BufferedReader over Scanner
here’s a code about depth first search in graphs. who knows why bufferedReader class were used in this code? and why nextInt function not used instead? what is its privilege? is it for speeding up processing? Thanks 🙂 Answer It’s an issue of how you intend to use the stream. A buffered reader exis…
What is inverse function to XOR?
There is XOR function in Java – a^b For exemple: 5^3 = 6 Can you tell me inverse function? If I have 6 and 3 can i get range of numbers which include number 5? Answer The inverse is XOR! If you have: You can get a or b back if you have the other value available: For example if
ResultSet getFetchSize() doesn’t seem to work?
I’m having trouble with the getFetchSize() function. I simply need to know if the SQL query has returned zero rows. I’ve tried this simple statement: where rs is of the ResultSet type. The above code doesn’t seem to work. It always prints the message whether rs is empty or not. I checked the…
org.apache.commons.io.FileUtils.readFileToString and blanks in filepath
I am trying to read a file to string using org.apache.commons.io version 2.4 on windows 7. but it fails with: but if I do: I works fine. So when I manually type the path with a space/blank it works but when I create it from an url it does not. What am I missing? Answer Try this: BTW since you
ServletContextListener SEVERE: Error configuring application listener of class marktest.Config
My Java servlet appears to be complaining that it can’t find a file which is included in the package (marktest). Im using Eclipse (Indigo) to develop and Tomcat7. Here is the error: Here is Config.java which contains the class implementing ServletContextListener which it says it can’t find in the …
JavaFX 2 set/get cursor position
How can I set/get the cursor’s position in JavaFX 2? I tired googling the answer but found nothing useful. All I can do is setting the cursor’s style. Answer You can use robot for that purpose: AWT robot: http://docs.oracle.com/javase/1.5.0/docs/api/java/awt/Robot.html or glass robot: com.sun.glas…
Check if arraylist contains only nulls
I think there has to be a better way of doing this.. I have a call to a function that returns an ArrayList. If that ArrayList only returns 10 null items (the default), is there a way of checking this without iterating through all 10 items to see if they are null? Answer Generally, no; there is no other way
Retrieve Context from a fragment
I created a class to retrieve comments from a JSON encoding from a PHP file. This class, extends from AsyncTask: As you can see, I’m trying to show a ProgressDialog while the “doInBackground” proccess is working. But progressDialog constructor, asks for a Context, and I don’t know how …