import java.io.BufferedReader;
import java.io.FileReader;
/**
* BufferedReader: Reads text from a character-input stream
* BufferedReader implements AutoCloseable, that allows try-with-resource to close automatically.
*/
public class TryWithResourceExample
{
public static void main(String[] args) throws Exception {
try(BufferedReader breader = new BufferedReader(new FileReader(args[0]))) {
System.out.println(breader.readLine()) ;
}
}
}
import java.io.FileReader;
/**
* BufferedReader: Reads text from a character-input stream
* BufferedReader implements AutoCloseable, that allows try-with-resource to close automatically.
*/
public class TryWithResourceExample
{
public static void main(String[] args) throws Exception {
try(BufferedReader breader = new BufferedReader(new FileReader(args[0]))) {
System.out.println(breader.readLine()) ;
}
}
}
No comments:
Post a Comment