import java.io.*;
public class AppFIS
{
public static void main(String[] args)
{
// Local variables and object references.
File fd;
FileInputStream in;
// Get the path name from the user.
System.out.print(“Enter the file’s complete path name: “);
fd = new File(Keyboard.readString());
// Try to read data from the input stream.
try
{
// Open an input stream for the file.
in = new FileInputStream(fd);
// This loop reads a byte from the stream and displays
// its value. The loop ends when no more bytes are available.
while (in.available() > 0)
{
System.out.println(in.read());
}
// Close the stream.
in.close();
System.out.println(“Closed – ” + fd.getPath());
}
// Catch an IOException if one is thrown.
catch (IOException e)
{
System.out.println(e.getMessage());
}
}
} |