Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
0 user currently in Programming. | 3 guests
Acmlm's Board - I2 Archive - Programming - Java
  
User name:
Password:
Reply:
 

UserPost
neotransotaku
Posts: 313/4016
that won't work because he wants bytes 0x1200 through 0x120f, not the string "1200". to do what he wanted, your code would have to say:

inputstring.substring(0x1200, 0x1210);

that would work if he read the entire file as text. however, because Java is unicode, meaning 1 character is two bytes, that might not do as he want. therefore, he should stick with the File I/O classes Java provides.
HellSavior
Posts: 4/41
Originally posted by Apophis
I see there how to read the data into the buffer at a certain offset, but how do I read the data from a particular offset in the file, ie bytes 1200-120f of the file.


Can you not input the line as a string, then do
inputstring.substring(inputstring.indexOf("1200"),inputstring.length());

, to grab the string after the offset?
MathOnNapkins
Posts: 16/2189
Apophis, I had to learn about file input and output in Java for one of my recent projects. If you have any questions feel free to ask. But some of my methods may be a little bit of overkill, in that they use File Channels.

I wrote a class specifically for reading files called GenericFileIO. Ask if you'd want it.
neotransotaku
Posts: 239/4016
Yes, it would be...anyways, if you have any Java questions, don't hesitate to ask me...I think I'm this board's only Java expert...and only Java advocate...heh
Apophis
Posts: 115/882
Thanks. I'm hoping to write editors in the future. Would be hard if I couldn't do this.
neotransotaku
Posts: 228/4016
You want to use Java.io.RandomInputFile. Then call it's seek method to move the "head" to where you want it to start reading. Then start reading away.
Apophis
Posts: 112/882
I see there how to read the data into the buffer at a certain offset, but how do I read the data from a particular offset in the file, ie bytes 1200-120f of the file.
Master Vivi
Posts: 5/46
Did you try the InputStream read method?
Apophis
Posts: 109/882
Does anyone know how to read hex data from a particular offset in Java? My textbook only covers reading strings sequentially, terminating everytime it reaches the end of line value.
Acmlm's Board - I2 Archive - Programming - Java


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.010 seconds.