Link to home
Start Free TrialLog in
Avatar of cbrune
cbrune

asked on

How do I get the byte position of the first character in a line?? the first chracter byte position of each reader.readline???

How do I get the byte position of the first character in a line??  the first chracter byte position of each reader.readline???


  private static void displayTextInputStream(InputStream input)
    throws IOException {
          // Read one text line at a time and display.
        BufferedReader reader = new BufferedReader(new
                    InputStreamReader(input));
        while (true) {
            String line = reader.readLine();
            if (line == null) break;

            System.out.println("    " + line);
        }
        System.out.println();
    }
Avatar of krakatoa
krakatoa
Flag of United Kingdom of Great Britain and Northern Ireland image

String line = reader.readLine();

Each 'line' is a String. So the position of the first character in it will be 0 in the CharSequence array.
Avatar of cbrune
cbrune

ASKER

I mean the overall byte mark of the starting character for the whole file
I mean the overall byte mark of the starting character for the whole file

What do you mean by "overall byte mark" ? The number of bytes will usually be the same as the number of characters in the file.
Avatar of cbrune

ASKER

if i need to skip to the beginning of a certain line in  the file.  as you are reading line by line I need the first byte position marker of where it is in the whole file so I can skip to that particular position.


"position here"test,test,test
"position here"test1,test1,test1
"position here"test2,test2,test2

So I can skip to the front of the line and read the whole record
ASKER CERTIFIED SOLUTION
Avatar of krakatoa
krakatoa
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Closed.