Return to Snippet

Revision: 35031
at November 1, 2010 10:41 by studioevoque


Initial Code
private String readFile(String pathname) throws IOException {
    StringBuilder stringBuilder = new StringBuilder();
    Scanner scanner = new Scanner(new File(pathname));

    try {
        while(scanner.hasNextLine()) {        
            stringBuilder.append(scanner.nextLine() + "\n");
        }
    } finally {
        scanner.close();
    }
    return stringBuilder.toString();
}

Initial URL

                                

Initial Description

                                

Initial Title
Read file to string

Initial Tags
java

Initial Language
Java