Forum: Java 5 Days Ago |
| Replies: 8 Views: 168 Try using the DocumentBuilderFactory instead of explicitly instantiating the parser.public static void main(String args[]) throws Exception {
DocumentBuilder builder =... |
Forum: Java 8 Days Ago |
| Replies: 2 Views: 205 NumberFormat is an abstract class; use its static factory method to get your choice of number formatter.public class MainTest {
public static void main(String args[]) throws Exception {
... |
Forum: Java 10 Days Ago |
| Replies: 2 Views: 249 The commas and the brackets are a part of the ArrayList class's toString() implementation. If you need your own row representation, either write your own method which does so or better yet, create a... |
Forum: Java 12 Days Ago |
| Replies: 20 Views: 494 Use getValues().nextLine().equals("n") instead. The Scanner name is confusing BTW, just name it scanner instead of getValues which is more appropriate for a method name. |
Forum: Java 12 Days Ago |
| Replies: 20 Views: 494 You are comparing a Scanner object with a String object. |
Forum: Java 21 Days Ago |
| Replies: 16 Views: 749 What's wrong with the getTime() method of the Date class which returns the number of milliseconds elapsed since January 1970 as long? To get the seconds, just divide by 1000. |
Forum: Java 22 Days Ago |
| Replies: 16 Views: 749 > is it possible to loop through the contents of two arrays to populate a
> third array with the combined content?
In my code I'm using looping through two Lists and populating a third list... |
Forum: Java 23 Days Ago |
| Replies: 16 Views: 749 Sadly, this simple a thing becomes pretty clunky to implement when it comes to Java. A sample implementation might be something like:
class YourClass {
private static final List<String>... |
Forum: Java 23 Days Ago |
| Replies: 16 Views: 749 > Does anybody know how I can append to the array
You can't. The best you can do is perform a copy-on-write if the content to be written is more than the initial capacity with which the array was... |
Forum: Java Oct 21st, 2009 |
| Replies: 6 Views: 339 IMO, though the analysis is correct, the solution provided isn't because an Iterator over a collection of elements of type E isn't the same as an Iterator over a collection of elements of type F... |
Forum: Java Oct 5th, 2009 |
| Replies: 4 Views: 3,277 There are many good books, blog posts and articles out there for getting started with JEE; your best bet would be the free JEE 5 tutorial (http://java.sun.com/javaee/5/docs/tutorial/doc/)hosted by... |
Forum: Java Oct 2nd, 2009 |
| Replies: 4 Views: 3,277 > also, would this be something to do with JavaEE instead of JavaSE?
Depends on what you need to learn and where your expertise lies, but yeah, nowadays the core business functionality *is*... |
Forum: Java Sep 24th, 2009 |
| Replies: 2 Views: 398 > But in second, I am getting exception that filenotfound.
Because the file "spring.xml" is not present at the root of the class path; you need to state the hierarchy or the path to your config... |
Forum: Java Sep 21st, 2009 |
| Replies: 10 Views: 1,080 Your second file is missing the class imports. I don't see the declaration of your `Convert' enum class. Your naming conventions are still off.
These are pretty simple error messages to hunt down... |
Forum: Java Sep 21st, 2009 |
| Replies: 10 Views: 1,080 A few observations:
- Always perform resource cleanup in the `finally' block to be rest assured that the cleanup indeed is performed even if the code ends up throwing an exception.
- The way you... |
Forum: Java Sep 20th, 2009 |
| Replies: 10 Views: 1,080 >Thanks a lot guys for the help!
Good luck with the remaining exercises.
> I will flag this as solved when I get my account fixed.
Done and done. :-) |
Forum: Java Sep 20th, 2009 |
| Replies: 10 Views: 1,080 Read the contract of the substring method; substring(4, 6) == 2 characters.
Also get in the habit of using uppercase characters for enums i.e. `BIN' instead of `bin'. |
Forum: Java Sep 14th, 2009 |
| Replies: 4 Views: 468 > How do I do that....I'm very new to Java
Steps:
Declare a TreeSet<String> instance variable for your class
Read the file using Scanner
For each line read, create the PublisherRecord... |
Forum: Java Sep 13th, 2009 |
| Replies: 4 Views: 468 > Using the TreeSet class, how do I accomplish this
It's pretty simple; just keep on reading the lines from the text file and add the last entry i.e. the publisher name to a TreeSet<String>. So... |
Forum: Java Sep 13th, 2009 |
| Replies: 2 Views: 601 > I think I need multiple loops to get rid of the commas, dollar sign, and
> end bracket separately.
Not required IMO; a single application of the replaceAll method of the String class on each... |
Forum: Java Aug 8th, 2009 |
| Replies: 5 Views: 350 >The Java platform supports a simple, deterministic scheduling
>algorithm called fixed-priority scheduling
Any official links? AFAIK, the JVM specification makes no such claim and leaves the... |
Forum: Java Jul 26th, 2009 |
| Replies: 7 Views: 382 Read the Javadocs of the classes ResultSetMetaData and DatabaseMetaData for more details regarding your database/table etc. A simple web search for these classes might give you sample snippets on how... |
Forum: Java Jul 10th, 2009 |
| Replies: 2 Views: 957 You need the mail.jar in your classpath; you need to download the JavaMail jars if you already don't have them.
You would also be needing the Java Activation Framework libraries [activation.jar]... |
Forum: Java Jul 10th, 2009 |
| Replies: 3 Views: 364 Also, no need to do calendar.setTime(time) ; the new instance of the calendar has the current time.
BTW, if you find yourself fiddling around a lot with time related methods in your application,... |
Forum: Java Jul 5th, 2009 |
| Replies: 4 Views: 404 Yes, Java 7 indeed seems to bring a lot of interesting things (http://tech.puredanger.com/java7) to the table. More confusion FTW!
> What I meant by "real" file system was simply that [...]
My... |
Forum: Java Jul 4th, 2009 |
| Replies: 4 Views: 404 > but it seems to work with a "real" file system on a "client side".
I'm not really sure what you mean by a `real' file system; the File class provides an `abstract filesystem independent view' of... |
Forum: Java Jun 26th, 2009 |
| Replies: 5 Views: 292 Let's suppose that your program creates regex patterns based on the input provided by the user. Assuming the user enters `*' as the pattern and `hello' as the input string, the regular expression... |
Forum: Java Jun 26th, 2009 |
| Replies: 5 Views: 292 > Is the best way to do this using a Trie?
Judging by its description, it does seem to be a good way of doing things, better than regular expressions at least when used over a large data set.
A... |
Forum: Java Jun 23rd, 2009 |
| Replies: 7 Views: 567 Marking this thread as solved since you already started a new thread which is a continuation of this one. |
Forum: Java Jun 23rd, 2009 |
| Replies: 7 Views: 567 A simple way would be to remove all opening brackets "(" in your String and then split on ")," to get the desired result.
Another way would be to use the Pattern and Matcher object to do the same... |
Forum: Java Jun 9th, 2009 |
| Replies: 3 Views: 208 Look into the batch execution capabilities (http://java.sun.com/j2se/1.3/docs/guide/jdbc/spec2/jdbc2.1.frame6.html) of JDBC. |
Forum: Java Jun 5th, 2009 |
| Replies: 5 Views: 362 > want to learn JNI , please suggest me some basic guide.
If you are doing it for fun, refer to the links posted above. But if you actually plan on writing a *real* application which requires... |
Forum: Java May 26th, 2009 |
| Replies: 12 Views: 797 Posting complete solutions never has and never will help. How about giving the OP a chance to try out a few things before handing out a solution? |
Forum: Java May 26th, 2009 |
| Replies: 12 Views: 797 Let me again point you to my first post in this thread which clearly mentioned:
Does that ring a bell? Think what could have gone wrong, give it a second try and reproduce the entire session again... |
Forum: Java May 25th, 2009 |
| Replies: 12 Views: 797 Post the code of the class "as it is" without *any* modification, including the package declaration. Also paste the *exact* error message along with a screenshot of the entire session.
This... |
Forum: Java May 25th, 2009 |
| Replies: 12 Views: 797 > So you would have to execute the command in this way :
> javac HelloWorldApp the class loader would look for a file with that
> name and a .class extension
A typo maybe? It should be java... |
Forum: Java May 4th, 2009 |
| Replies: 7 Views: 561 Like I had previously mentioned, there is no need to loop over the result of the split method call. The split method returns an array whose elements are the host, ip addr and the ping.
Just remove... |
Forum: Java May 4th, 2009 |
| Replies: 7 Views: 561 Post your latest copy of compilable code which exhibits the behavior you mention [i.e. duplicate printing] along with the relevant CSV file. |
Forum: Java May 4th, 2009 |
| Replies: 7 Views: 561 > it duplicates the information its printing out by 3
Because you print out the information in a loop. The solution here is pretty simple; split the string read from the file/stdin using the given... |
Forum: Java May 1st, 2009 |
| Replies: 3 Views: 399 I think the OP is talking about the "copy constructor" like functionality which exists in C++ and can be implemented in Java by:
- implementing the Cloneable interface
- overriding the clone()... |