How can i convert File to Binary? I just need it for my project. I need to encrypt a file by its binaries.
try {
StringBuilder sb = new StringBuilder();
File file = new File("C:/log.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();
}