• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

read n bytes field name

 
David Dong
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

can anyone helpe me solve this.
I don't know how I can read an n byte field name, where n bytes come from s1 length of field name .

I am getting weird character output.
 
Anton Golovin
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Big Head Moose:
Hi ,

can anyone helpe me solve this.
I don't know how I can read an n byte field name, where n bytes come from s1 length of field name .

I am getting weird character output.


Welcome to the forum. I bet the bartender is going to ask you to change your name according to their naming policy. As to your question, I use a RandomAccessFile to read from an nth element. It also lets you specify the number of bytes to read.

If you are getting a weird character output, this may be due to the incorrect translation of the bytes into the correct character set. Try to use the new String(byte[] chars, Stirng characterSet) constructor for the String object.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11946
212
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Big Head Moose,

Welcome to JavaRanch and this forum.

We don't have many rules here, but one we do have is the JavaRanch Official Policy On Displayed Names, which requires your displayed name to be a real name.

Could you please change your displayed name to meet this policy? You can change it here.

Thanks,

Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic