Register | Login | |||||
Main
| Memberlist
| Active users
| ACS
| Commons
| Calendar
| Online users Ranks | FAQ | Color Chart | Photo album | IRC Chat |
| |
0 user currently in Programming. | 3 guests |
Acmlm's Board - I2 Archive - Programming - Java | | | |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread |
User | Post | ||
Apophis Red Super Koopa Level: 45 Posts: 109/882 EXP: 640255 For next: 19909 Since: 03-15-04 Since last post: 15 hours Last activity: 15 hours |
| ||
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. | |||
Master Vivi Blue Octorok Level: 12 Posts: 5/46 EXP: 7608 For next: 313 Since: 03-17-04 Since last post: 287 days Last activity: 263 days |
| ||
Did you try the InputStream read method? | |||
Apophis Red Super Koopa Level: 45 Posts: 112/882 EXP: 640255 For next: 19909 Since: 03-15-04 Since last post: 15 hours Last activity: 15 hours |
| ||
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. | |||
neotransotaku Baby Mario 戻れたら、 誰も気が付く Level: 87 Posts: 228/4016 EXP: 6220548 For next: 172226 Since: 03-15-04 From: Outside of Time/Space Since last post: 11 hours Last activity: 1 hour |
| ||
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 Red Super Koopa Level: 45 Posts: 115/882 EXP: 640255 For next: 19909 Since: 03-15-04 Since last post: 15 hours Last activity: 15 hours |
| ||
Thanks. I'm hoping to write editors in the future. Would be hard if I couldn't do this. | |||
neotransotaku Baby Mario 戻れたら、 誰も気が付く Level: 87 Posts: 239/4016 EXP: 6220548 For next: 172226 Since: 03-15-04 From: Outside of Time/Space Since last post: 11 hours Last activity: 1 hour |
| ||
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 | |||
MathOnNapkins Math n' Hacks Level: 67 Posts: 16/2189 EXP: 2495887 For next: 96985 Since: 03-18-04 From: Base Tourian Since last post: 1 hour Last activity: 32 min. |
| ||
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. |
|||
HellSavior Red Goomba Level: 12 Posts: 4/41 EXP: 6398 For next: 1523 Since: 03-18-04 Since last post: 212 days Last activity: 110 days |
| ||
Originally posted by Apophis 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? |
|||
neotransotaku Baby Mario 戻れたら、 誰も気が付く Level: 87 Posts: 313/4016 EXP: 6220548 For next: 172226 Since: 03-15-04 From: Outside of Time/Space Since last post: 11 hours Last activity: 1 hour |
| ||
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. |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread |
Acmlm's Board - I2 Archive - Programming - Java | | | |