Java: Read file from specific point till end of line

1.1k views Asked by At

How do I read a file from a specified position to the end of that line.

Example:

File Contents:

01234567
f1=value
f2=value
f3=value

01234567 = character position. I want it to start reading the line from the "v" in value and I want it to read till the end of the line. So the position would be 3.

2

There are 2 answers

0
Steve Kuo On

Run your text file through colrm first. Or, when reading each line pragmatically, use String.substring.

0
MadProgrammer On

Have a look at FileInputStream.skip

If that doesn't work, you could try reading n bytes from the stream to put at the start read position (preferably via blocks instead of a byte at a time)