import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
public class JavaApplication1 {
public static void main(String[] args) throws Exception {
try (DataInputStream in = new DataInputStream(new FileInputStream("D:\\a.txt"))) {
int bytesRead = 0;
int bytesToRead = 1024;
byte[] b = new byte[bytesToRead];
while( bytesRead < bytesToRead) {
int result = in.read(b, bytesRead, bytesToRead - bytesRead);
if(result == -1) {
break;
}
bytesRead += result;
}
String str = new String(b);
System.out.println(str);
} catch (IOException ex) {
System.out.println(ex.getMessage());
}
}
}