The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > java.io  [35 examples] > Reading and Writing  [6 examples]

e35. Reading Text from a File

    try {
        BufferedReader in = new BufferedReader(new FileReader("infilename"));
        String str;
        while ((str = in.readLine()) != null) {
            process(str);
        }
        in.close();
    } catch (IOException e) {
    }

 Related Examples
e34. Reading Text from Standard Input
e36. Reading a File into a Byte Array
e37. Writing to a File
e38. Appending to a File
e39. Using a Random Access File

See also: Directories    Encodings    Filenames and Pathnames    Files    Parsing    Serialization   


© 2002 Addison-Wesley.