-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFiletoBinary.java
More file actions
25 lines (23 loc) · 799 Bytes
/
FiletoBinary.java
File metadata and controls
25 lines (23 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import java.io.*;
public class FiletoBinary {
static StringBuilder sb;
public static void main(String[] args)
{
try {
StringBuilder sb = new StringBuilder();
File file = new File("Files\\test\\file_to_check.txt");
DataInputStream input = new DataInputStream( new FileInputStream( file ) );
try {
while( true ) {
sb.append( Integer.toBinaryString( input.readByte() ) );
}
} catch( EOFException eof ) {
} catch( IOException e ) {
e.printStackTrace();
}
System.out.println(sb.toString());
} catch( FileNotFoundException e2 ) {
e2.printStackTrace();
}
}
}