java - How do I use the substr function to grab the last 100 bytes of a 32K in length string? -


summary question: how correctly use substr function grab last 100 bytes of 32k in length string in java?

i have admit c/c++ slim , little used , java experience these couple of programs fighting with.

just trying test of passing string , forth mainframe comfortzone (no comments please... ;-)...not in wheelchair @ least 3 decades....really!)

the string under 32k , on pc eclipse ide side have defined as:

string hold_container_data = cont.getchardata(); 

the sample copied defaulted printing system.out.println 10 strings of 32k overwhelming ide console. trying fix that.

so wanted display first 100 , last 100 bytes since diagnostic display handy have working.

got first 100 bytes with:

hold_container_data.substring( 0, 100 ); 

started with:

hold_container_data.substring( length-100, 100 ); 

which figured might syntax issue though compiled fine.

for grins tried both:

hold_container_data.substring( 31000, 100 ); hold_container_data.substring( 500, 100 ); 

the latter receives a:

 java.lang.stringindexoutofboundsexception: string index out of range: -400     @ java.lang.string.substring(unknown source) 

again grins tried:

hold_container_data.substring( 10, 100 ); 

which sort of worked?

and:

hold_container_data.substring( 100, 100 ); 

which seemed print blanks?? when positions should not white space.

when use following:

int mylength = hold_container_data.length(); 

and print with:

system.out.println 

the value correct actual string length is?

i use debugger , @ arg0 , arg1 substring function string data area , fine limited use of java?

so there must extremely simple missing here?

could please enlighten me area can look?

thanks in advance patience me on new developer platform!

having @ javadocs thing, many questions answered there. example substring has second function copy last chars starting x.

hold_container_data.substring(hold_container_data.length() - 100); 

will trick.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -