public static void main(String[] args) throws FileNotFoundException, IOException {
File files = new File("C:\\ClassAlgodao");
for (File file : files.listFiles()) {
System.out.println(file);
BufferedReader ler = new BufferedReader(new FileReader(file));
String txt = null;
txt = ler.readLine();
String[] spli = txt.split("###");
int num=0;
while(!"".equals(spli[num])){
num++;
System.out.println(num);
}
ler.close();
}
}
ERRO:
run:
C:\ClassAlgodao\11.txt
1
2
3
4
5
6
7
8
9
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 12
10
11
12
at lendosplitvariostamanhos.Lendosplitvariostamanhos.main(Lendosplitvariostamanhos.java:31)
Java Result: 1
CONSTRUÍDO COM SUCESSO (tempo total: 5 segundos)
O q devo fazer para resolver