CIS 35A: Introduction to Java Programming

Home | Green Sheet | Lectures | Assignments | FAQ | Grades

Files

Text and Binary Files
Introduction
How is I/O Handled in Java?

A File object encapsulates the properties of a file or a path, but does not contain the methods for reading/writing data from/to a file. In order to perform I/O, you need to create objects using appropriate Java I/O classes.

Scanner input = new Scanner(new File("temp.txt"));
System.out.println(input.nextLine());

Formatter output = new Formatter("temp.txt"); output.format("%s", "Java 101"); output.close();
Previous | How is I/O Handled in Java? | Text File vs. Binary File | Object I/O | FileInputStream/FileOutputStream | FilterInputStream/FilterOutputStream | ObjectInputStream/ObjectOutputStream | BufferedInputStream/ BufferedOutputStream | DataInputStream/DataOutputStream | Next