byte - How to extract values between specific sequence in java -


this file reading how specific value file.

i want data

starting form 2000 466 character , starting 4000 550(it can there or ellse empty) , data 6000 328 characters.

ie

line 1 : starts character 2000 466 characters line 2 : starts character 4000 550 characters line 3 : starts character 4000 550 characters line 4 : starts character 6000 328 characters 

and ignore remaining part file header , file footer.

what did far is

update

stringbuilder sb = new stringbuilder(); newsize = in.readline(buffer); system.out.println("newsize-------------"+newsize); while (newsize > 0) {  string str = buffer.tostring();  sb.append(str);  sb.append("\n");  newsize = in.readline(buffer); } string s = sb.tostring(); /*  * differentiating header,body , footer  */ if(s.length() >0){   string header = sb.tostring().substring(0,466);  system.out.println("header-------------------"+header);   //unable body part } 

how body part?

you can by:

  • read whole content of file in string variable.
  • call substring method specific char index

note: have check string variable length before calling substring method avoid out of bound exception.

update

if you, ill not use fixed value sub string value, ill use indexof method determine index should sub string.

for example:

int startindex= filecontent.indexof("some unique starting characters"); int endindex = filecontent.indexof("some unique endingcharacters"); 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -