aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes My code isn't running on sites like codechef and oneide Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "My code isn Watch "My code isn New topic
Author

My code isn't running on sites like codechef and oneide

Rahul Son
Greenhorn

Joined: Sep 23, 2011
Posts: 1
My code is running correctly on my NetBeans6.5 IDE.But when I submitted it on CodeChef and OneIDE if gave runtime error
My Code is:

The error comes at the user input line for v.For BufferedReader its .........

Exception in thread "main" java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:417)
at java.lang.Integer.parseInt(Integer.java:499)
at a.main(Main.java:31)

And with using Scanner for user input.......

my code using Scanner as well...



the error msg is..........

Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:838)
at java.util.Scanner.next(Scanner.java:1461)
at java.util.Scanner.nextInt(Scanner.java:2091)
at java.util.Scanner.nextInt(Scanner.java:2050)
at A01.main(Main.java:27)

Anyone please tell why is happening and how can I remove these errors which are not being shown on my IDE,infact both these codes are working well on my IDE but not on these sites compilers.Last night iI had to withdrew from an online competition because of this problem.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42612
    
  65
For starters, never do this:

You simply MUST handle exceptions, especially I/O exceptions. At least print an error message someplace where you will see it.

It's hard to tell what the program will do without knowing the input you gave. I would guess that whatever string you ran through "parseInt" wasn't in fact an integer - it may have been empty or null.

In the future, please UseCodeTags. See how much easier to read the code is now?


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: My code isn't running on sites like codechef and oneide