The Artima Developer Community
Sponsored Link

Java Answers Forum
File I/O questions

1 reply on 1 page. Most recent reply: Feb 25, 2003 4:17 PM by Matt Gerrans

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
Earl Scruggs

Posts: 1
Nickname: skanmand1
Registered: Feb, 2003

File I/O questions Posted: Feb 24, 2003 10:30 PM
Reply to this message Reply
Advertisement
I have a few questions about this code? They follow the code.

import java.io.*;

public class TestFileIO {

public static void main(String[] args) {


String name="John Smith";
double salary = 23493.23;
int age = 54;

try {
File testFile;
testFile = new File("testfile.txt");

FileWriter charOutput;
charOutput = new FileWriter(testFile);

PrintWriter out;
out= new PrintWriter(charOutput);

out.println(name);
out.println(salary);
out.println(age);
out.close();


} catch(IOException e) {
e.printStackTrace();
}
}
}

1. Does java.io.* give the programmer the ability to access files on disk?
2. Does this class need to implement "seralizable" to work properly?
3. Is "File" a class that allows writing directly to the file?
4. Is "testFile" a reference variable?
5. Is "salary" a reference variable?
6. Will the "try" statement catch I/O errors?
7. Does "FileWriter" send only numbers to a file and not strings?
8. Will "PrintWriter" send strings to a file?
9. Is "System.out" and "out" the same things?
10. Is IOException a class?
11. Must all exceptions be named "e"?
12. Is the "try" statement required or will you get a compiler error?
13. Will exceptions catch all compiler errors?
14. Do all exceptions have a parent class called "Exception"?


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: File I/O questions Posted: Feb 25, 2003 4:17 PM
Reply to this message Reply
Yes and no. I'd say about 36% yes on the whole.

Flat View: This topic has 1 reply on 1 page
Topic: Unloading class loader Previous Topic   Next Topic Topic: get paid to help me.

Sponsored Links



Google
  Web Artima.com   

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