Results 1 to 9 of 9
Thread: Error in DataInputStream
- 07-10-2011, 02:43 AM #1
Member
- Join Date
- Jul 2011
- Location
- India
- Posts
- 6
- Rep Power
- 0
Error in DataInputStream
Hi,
This is my first thread,iam using Jcreator IDE for running java programs
I got the following error when i executed the program
/*number1=Integer.parseInteger(in.readLine());
number2=Integer.parseInteger(in.readLine());
res=Integer.parseInteger(in.readLine());
*/
Error: D:\jp\new6.java:13: cannot find symbol
symbol : method parseInteger(java.lang.String)
location: class java.lang.Integer
number1=Integer.parseInteger(in.readLine());
^
D:\jp\new6.java:14: cannot find symbol
symbol : method parseInteger(java.lang.String)
location: class java.lang.Integer
number2=Integer.parseInteger(in.readLine());
^
D:\jp\new6.java:15: cannot find symbol
symbol : method parseInteger(java.lang.String)
location: class java.lang.Integer
res=Integer.parseInteger(in.readLine());
^
Note: D:\jp\new6.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
3 errors
Process completed.
Thanks in advance!
- 07-10-2011, 02:57 AM #2
It looks like a compiler error, not an execution time error.I got the following error when i executed the program
The compiler can't find the parseInteger(java.lang.String) method in the class java.lang.Integer.
Read the API doc for the Integer class to be sure you are spelling the method name correctly.
- 07-10-2011, 03:41 AM #3
Member
- Join Date
- Jul 2011
- Location
- India
- Posts
- 6
- Rep Power
- 0
Thanks for ur suggestion but i could not find out the error so i post the whole program below just check and provide a solution please
import java.io.*;
import java.lang.*;
class new6
{
public static void main(String args[])
{
DataInputStream in =new DataInputStream(System.in);
int number1;
int number2;
int res;
System.out.println("Enter the two values for Addition");
number1=Integer.parseInt(in.readLine());
number2=Integer.parseInt(in.readLine());
res=Integer.parseInt(in.readLine());
res=number1+number2;
System.out.println("The result is : " + res);
}
}
- 07-10-2011, 03:59 AM #4
Please explain what your problem is?provide a solution please
Post the error messages here.
- 07-10-2011, 04:28 AM #5
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
We aren't here to fix your code, instead we give you the information necessary to fixing the problem(links to API docs, or explaining why something isn't working), provide us with the errors. Not everyone is willing/able to compile and run the code.
Read this link(mainly what it says about readLine()): http://download.oracle.com/javase/6/...putStream.html
If you are simply reading from the console I suggest you use a scanner instead: http://download.oracle.com/javase/6/...l/Scanner.html
And if you want to work with the streams instead, check this out: http://download.oracle.com/javase/tu.../essential/io/Last edited by sunde887; 07-10-2011 at 04:33 AM.
- 07-10-2011, 02:13 PM #6
Member
- Join Date
- Jul 2011
- Location
- India
- Posts
- 6
- Rep Power
- 0
I posted the errors ,.suggest me a solution
D:\jp\new6.java:13: unreported exception java.io.IOException; must be caught or
declared to be thrown
number1=Integer.parseInt(in.readLine());
^
D:\jp\new6.java:14: unreported exception java.io.IOException; must be caught or
declared to be thrown
number2=Integer.parseInt(in.readLine());
^
D:\jp\new6.java:15: unreported exception java.io.IOException; must be caught or
declared to be thrown
res=Integer.parseInt(in.readLine());
^
Note: D:\jp\new6.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
3 errors
- 07-10-2011, 02:15 PM #7
Member
- Join Date
- Jul 2011
- Location
- India
- Posts
- 6
- Rep Power
- 0
Hi,I get u that u r not there to fix our code,.
I posted the errors now
suggest a solution
Thanks in advance
- 07-10-2011, 02:18 PM #8
The statement that is referred to throws an IOException. You should put that code inside of a try{}catch(){} block that catches that exception.java.io.IOException; must be caught
- 07-10-2011, 02:37 PM #9
Member
- Join Date
- Jul 2011
- Location
- India
- Posts
- 6
- Rep Power
- 0
Similar Threads
-
DataInputStream
By robs in forum Java GamingReplies: 7Last Post: 04-14-2011, 06:27 PM -
DataInputStream to file
By jasondeegan in forum New To JavaReplies: 5Last Post: 06-16-2010, 03:35 PM -
Problem with DataInputStream
By ZivonHunter in forum New To JavaReplies: 1Last Post: 11-21-2008, 05:10 AM -
DataInputStream readLine()
By ravian in forum New To JavaReplies: 2Last Post: 11-26-2007, 10:44 PM -
Help with BufferedInputstream and/or DataInputStream
By barney in forum New To JavaReplies: 1Last Post: 08-07-2007, 07:16 AM


LinkBack URL
About LinkBacks
-.gif)
.gif)

Bookmarks