The Artima Developer Community
Sponsored Link

Java Answers Forum
Java I/O Problem(Thanks)

1 reply on 1 page. Most recent reply: Aug 31, 2003 7:56 PM by Charles Bell

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Jack

Posts: 6
Nickname: daxian2003
Registered: Apr, 2003

Java I/O Problem(Thanks) Posted: Aug 26, 2003 11:30 PM
Reply to this message Reply
Advertisement
import java.io.*;

public class IOProblem {
// Throw exceptions to console:
public static void main(String[] args)
throws IOException {
DataOutputStream out =
new DataOutputStream(
new BufferedOutputStream(
new FileOutputStream("Data.txt")));
out.writeDouble(3.14159);
out.writeBytes("That was the value of pi\n");
out.writeBytes("This is pi/2:\n");
out.writeDouble(3.14159/2);
out.close();

DataInputStream in =
new DataInputStream(
new BufferedInputStream(
new FileInputStream("Data.txt")));
BufferedReader inbr =
new BufferedReader(
new InputStreamReader(in));
// The doubles written BEFORE the line of text
// read back correctly:
System.out.println(in.readDouble());
// Read the lines of text:
System.out.println(inbr.readLine());
System.out.println(inbr.readLine());
// Trying to read the doubles after the line
// produces an end-of-file exception:
System.out.println(in.readDouble());
}
} ///:~


Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: Java I/O Problem(Thanks) Posted: Aug 31, 2003 7:56 PM
Reply to this message Reply
What was the question or problem?

Flat View: This topic has 1 reply on 1 page
Topic: Weblogic deployment Previous Topic   Next Topic Topic: game programming

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use