// Open a file for reading with Files.newInputStream() method, which
// returns a stream that can read bytes from a file
import java.nio.file.*;
import java.io.*;
public class ReadFile
{
public static void main(String[] args)
{
Path file = Paths.get( "C:/example/myfile.txt" );
InputStream input = null;
try
{
input = Files.newInputStream( file );
BufferedReader reader = new
BufferedReader( new InputStreamReader( input ) );
String str = null;
str = reader.readLine();
System.out.println( str );
input.close();
}
catch ( IOException ex )
{
System.out.println( ex );
}
}
}