W
www
Hi,
I have a binary file. I have no idea what is inside. They could be
numbers, or chars. I am trying to use Java to read it and print out to
the screen. Following is my program:
<Java>
import java.io.*;
public class CopyBytes {
public static void main(String[] args) throws IOException {
DataInputStream in = null;
try {
in = new DataInputStream(new
FileInputStream("binary_file_name"));
char c;
while ((c = in.readChar()) != -1) {
System.out.print(c);
}
} finally {
if (in != null) {
in.close();
}
}
}
}
</Java>
The print out to screen is very, very messy. I saw Korean letters,
Chinese letters printed out. I am wondering if I did it right.
Thank you for your help.
I have a binary file. I have no idea what is inside. They could be
numbers, or chars. I am trying to use Java to read it and print out to
the screen. Following is my program:
<Java>
import java.io.*;
public class CopyBytes {
public static void main(String[] args) throws IOException {
DataInputStream in = null;
try {
in = new DataInputStream(new
FileInputStream("binary_file_name"));
char c;
while ((c = in.readChar()) != -1) {
System.out.print(c);
}
} finally {
if (in != null) {
in.close();
}
}
}
}
</Java>
The print out to screen is very, very messy. I saw Korean letters,
Chinese letters printed out. I am wondering if I did it right.
Thank you for your help.