Skip to content

Instantly share code, notes, and snippets.

@rahul-rkt
Created June 7, 2012 20:06
Show Gist options
  • Save rahul-rkt/2891252 to your computer and use it in GitHub Desktop.
Save rahul-rkt/2891252 to your computer and use it in GitHub Desktop.
New way of reading files in Java 1.6
package test.file.reading;
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
public class NewJava {
public static void main(String[] args) throws IOException {
System.out.println("" + new Scanner(new File("test.txt")).useDelimiter("\\Z").next());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment