• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help analyze code  RSS feed

 
Davey Lopez
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone My job is to analyze this code I was wondering if someone can tell me if I'm on the right track or not.
-thanks again



OK here's what I have for the first half of the code(everything above fillerpos=f.getpointer)
first it starts off creating a long and int that part is obvious.
next it creates a long which according my sources i believe it will create a sequence of bytes length 8 with a values of zero?
so something like this
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
next the write chars I believe will go something like this,because it creates 2 bytes for every character?
[R][][A][][L][][P[][H][] etc

one Last thing my instructor showed us a command to actually print out the results but I forgot it would someone mind telling me.
I believe it had the word dump in it meanwhile ill start studying the other code
 
Mike. J. Thompson
Bartender
Posts: 689
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The best way to see what the code is doing would be to open the file you are writing to in a hex editor and inspecting the bytes.

You might also want to read the Javadoc for the RandomAccessFile which will tell you what the methods do.
 
Davey Lopez
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I tried this an got a bunch of characters from an unknown language between every english character not sure why.
for(int j=0;j<60;j++)
{
f.seek(j);
System.out.println(f.readChar());
}

R

a

l

p
瀀
h

l

i

k

e

s

J

a

v

a

 
Davey Lopez
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike. J. Thompson wrote:The best way to see what the code is doing would be to open the file you are writing to in a hex editor and inspecting the bytes.

You might also want to read the Javadoc for the RandomAccessFile which will tell you what the methods do.


yeah ive looked at those bet they're even less clear than the book examples i guess what I need is some real world examples
 
Davey Lopez
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well the characters are chinese that's what Ive discovered i believe for every english character it is giving me its chinese letter equivalent?
 
Campbell Ritchie
Marshal
Posts: 56527
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Get each char printed out as an int with printf and %x and see what their values are. Compare the values with a Unicode chart or the find by hex code box on that link.
 
Paul Clapham
Sheriff
Posts: 22819
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're on the wrong track entirely. What you see in the file are not "characters" at all. You are using methods like writeInt() and writeDouble() which write binary data, not intended to represent text at all. So using a tool which attempts to represent that data as text is misleading at best. Like Mike said, use a hex editor and look at the bytes which your code wrote to the file.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!