Java Read File

Scanner method can be slow for big file:
import java.io.*;
import java.util.*;

    private void readFile( String filename ) {
        try {
            Scanner in = new Scanner( new FileReader( filename ) );
            String line = in.nextLine();
            System.out.println( line );
        } catch ( FileNotFoundException e ) {
        }
    }

No comments:

Post a Comment