ask
ask

Reputation: 2230

BufferedReader reading garbage

I'm using BufferedReader to read some HEX dumps. But BufferedReader reads garbage values before the actual contents of the file.

Example:

Actual file contents looks like this (if I open it with an editor like vim):

02e9 9000 e890 0000 815e 08ee eb01 201a
754f 2072 6170 7473 6920 2073 6f20 7275
6620 7475 7275 2165 8b20 e9ee 018a 0000

What BufferedReader reads looks like this:

���Bud1������������á�����������������������������������������������������������E�v�i�l�.�c�������������������������������������������R�i�o�.�E�v�i�l�.�c�o�m�.�h�e�xIlocblob������F���(���ˇˇ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� �����
�@��������������������������������������� ������@����������������������������������������� ������@����������������������������������������� ������@�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������E���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������DSDB����������������������������� ���`�������������������������������������������� ������@����������������������������������������� ������@����������������������������������������� ������@��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
02e9 9000 e890 0000 815e 08ee eb01 201a
754f 2072 6170 7473 6920 2073 6f20 7275
6620 7475 7275 2165 8b20 e9ee 018a 0000

I don't understand what's happening. The first line contains part of the name of the file. Is there some meta-data that doesn't actually appear in the file. How do I ignore this?

My code snippet is pretty standard File I/O:

BufferedReader input = new BufferedReader(new FileReader(file));

String line = input.readLine();

while(line != null) {
  System.out.println(line);
  line = input.readLine();
}

Upvotes: 0

Views: 653

Answers (1)

ask
ask

Reputation: 2230

Figured it out. In OS X, a hidden folder .DS_Store exists in the directory. I was mass reading HEX dumps, so that file was included which led to the garbage values.

Upvotes: 3

Related Questions