File Input Output

Files come in two types in Java

I/O in Java

Specialized subclasses

Reading Data

Example Java™ API

import java.io;

File fileName = new File (testFile.txt); // a file object could be created with a GUI as in TextIO.java

BufferedReader br //br is the pipe between the file object and memory object
       = new BufferedReader(new FileReader(fileName));

String line = br.readLine(); // reading in a single line of text into the String object line
      // BufferedReader.readLine() returns
null when \eof is reached

br.close();

BACK