Help me plz error java.lang.StringIndexOutOfBoundsException: String index

Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 4
at java.lang.String.substring(Unknown Source)
at java.lang.String.subSequence(Unknown Source)
at com.example.tms.Import.ImportRount.readFile(ImportRount.java:950)
at com.example.tms.Import.ImportRount.checkfile(ImportRount.java:877)
at com.example.tms.Import.ImportRount.uploadSucceeded(ImportRount.java:1099)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:512)
… 25 more

Code :

public void readFile(){
try {
FileReader r2 = new FileReader(this.objCls.getFilePath());
FileReader r = new FileReader(this.objCls.getFilePath());
BufferedReader bro2 = new BufferedReader(r2);
BufferedReader bro = new BufferedReader(r);

	       // declare String variable and prime the read
		   String stringRead2 = bro2.readLine();
	       String stringRead ;
	       
	       int i = 1;
	       int j = 1;
	       while(stringRead2 != null){
	    	   stringRead2 = bro2.readLine();
	    	   
	    	   j++;

// System.out.println(j);
}
bro2.close();
// System.out.println("test JJJJ "+j);

	       while((stringRead = bro.readLine()) != null){
	    	   if(i>1 && i!=(j-1)){
	    		  final ImportRountAction act = (ImportRountAction)this.objAct;
	    		  final ImportRountClass data = (ImportRountClass)this.objCls;

				  //stringRead = bro.readLine();  // read next line	
				  data.setsaleog ((String) stringRead.subSequence(0,4));	==Eror			 
				  data.setShipPoint ((String) stringRead.subSequence(4,8));
				  data.setinvoice ((String) stringRead.subSequence(8,18));

i want to Import Excle File to DataBase Thank you

You are trying to get the four first characters from the stringRead string using subSequence. The StringIndexOutOfBoundsException means that either of the given indexes (0 and/or 4) is “out of bounds” of the string, meaning, the string’s length is less than the given index. My guess is that readLine returns and empty string (length 0). Before you can make a subsequence, you need to check the string’s length.

This question has nothing to do with Vaadin.

If it is a true Excel file, you should try the forums of some Java Excel library such as
Apache POI
or
jexcelapi
. Otherwise (e.g. for CSV), try some general Java forum.