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(
at com.example.tms.Import.ImportRount.checkfile(
at com.example.tms.Import.ImportRount.uploadSucceeded(
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(
… 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();

// System.out.println(j);
// 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
. Otherwise (e.g. for CSV), try some general Java forum.