这里文件read.txt包含多个unicode单词和代理对..在for循环中使用k = 3来从文件read.txt中获取多个三个字母的单词。我在计算代理对时遇到问题..(即)字符与变音符号一起计数...想要一些想法来计算代理对...当运行下面的代码时......得到这个错误......
java.lang.ArrayIndexOutOfBoundsException:13 在pp.main(pp.java:36) 建立成功(总时间:1秒)
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class pp {
public static void main(String[] args) throws IOException {
FileReader fr = null;
BufferedReader br =null;
FileWriter fw=null;
BufferedWriter bw=null;
String [] stringArray;
int arrayLength ;
String s="";
String stringLine="";
try{
fr = new FileReader("D:\\OFFICE\\read.txt");
fw=new FileWriter("D:\\OFFICE\\write.txt");
br = new BufferedReader(fr);
bw=new BufferedWriter(fw);
while((s = br.readLine()) != null)
{
stringLine = stringLine + s;
stringLine = stringLine + " ";
}
stringArray = stringLine.split(" ");
arrayLength=stringLine.codePointCount(0, stringLine.length());
for (int i = 0; i <arrayLength; i++)
{
for(int k=3;k>stringArray[i].length();i++)
//for getting all 3 char unicode lines
{
System.out.println(stringArray[i]);
bw.newLine();
}
int n=stringLine.offsetByCodePoints(0, i);
arrayLength=stringLine.codePointAt(n);
}
fr.close();
br.close();
bw.flush();
bw.close();
}catch (ArrayIndexOutOfBoundsException e) {
e.printStackTrace();
}}}