File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes readLine() Deprecated Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "readLine() Deprecated" Watch "readLine() Deprecated" New topic
Author

readLine() Deprecated

Nelson Nadal
Ranch Hand

Joined: Jun 06, 2002
Posts: 169
Is there no other way to read what the
DataOutputStream() created except by DataInputStream()?
My problem is how to read what
DataOutputStream.writeChars()
had made.
If I used readLine() of DataInputStream its deprecated...
Veena Rani
Ranch Hand

Joined: Mar 09, 2000
Posts: 34
You can use readLine method of BufferedReader class for reading from the DataInputStream
Wrap the DataInputStream in the BufferedReader object by using this code
BufferedReader d = new BufferedReader(new InputStreamReader(in));
where 'in' is the object of DataInputStream.
Nelson Nadal
Ranch Hand

Joined: Jun 06, 2002
Posts: 169
This is the code...


I changed to this...


Still it's not showing the right thing...
Veena Rani
Ranch Hand

Joined: Mar 09, 2000
Posts: 34
If you have created your file using DataOutStream writeInt, writeDouble etc. then only you can read it using readInt() or readDouble() etc.
If you have a simple text file then you can not use readInt or readDouble.
In case of normal text file with tab seperated data you can use BufferReader to read the line by line record and seperate the tab seperated data using StringTokenizer.
Your code will look something like this
while ((desc = brin.readLine()) != null) {
StringTokenizer st = new StringTokenizer(desc,"\t");
//some check for no. of tokens
unit = Integer.parseInt(st.nextToken());
price = Integer.parseInt(st.nextToken());
desc = st.nextToken();
System.out.println("You've ordered " +unit + " units of " +desc + " at $" + price);
System.out.println(desc);
total = total + unit * price;
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: readLine() Deprecated
 
Similar Threads
Input
Please Tell Me What This Means, And How To Fix It
How to read bytes to string regardless of encoding?
DataInputStream
Read a file line by line