I am scanning a text file in Java and reading it line by line using Buffered Reader. I have some text in its 60 to 80 th position. Depending upon the texts in this position I need to decide whether to skip the line or read some data from the same line. In this case if I find "END OF HEADER" I need to skip that line. I used bufferedreader.skip(line.lenght()) that is 80 here, to skip that line and move to next line to read some text but again it gives string out of range exception.
streamObs = new FileInputStream(obsFile);
inStreamObs = new InputStreamReader(streamObs);
buffStreamObs = new BufferedReader(inStreamObs);
BufferedReader in = new BufferedReader(new FileReader(obsFile));
String line="";
while((line = in.readLine()) != null)
{
String typeField=line.substring(Math.min(line.length(),60),line.length());
//System.out.println(typeField);
typeField=typeField.trim();
if (typeField.equals("RINEX VERSION / TYPE")) {
System.out.println(" Current version:"+line.substring(5,9));
}
if (typeField.endsWith("TIME OF FIRST OBS")){
System.out.println("Time of First Observation:"+ line.substring(2,44));
}
if (typeField.equals("END OF HEADER"))
{
in.skip(80);
}
System.out.println(line.substring(Math.min(line.length(),30),32));
}