


File file = new File("G:\\dd.txt");
InputStreamReader isr = new InputStreamReader(new FileInputStream(file), "GBK");
BufferedReader br = new BufferedReader(isr);
String all = "";
String lineTxt = null;
while ((lineTxt = br.readLine()) != null) {
all = all + lineTxt;
// System.out.println(lineTxt);
}
br.close();
isr.close();
for (int i = 1; i < 166; i++) {
int startIndex = all.indexOf(i + "."); // 开始截取的字符位置
int endIndex = all.indexOf(i + 1 + "."); // 最后截取的字符位置
String s1 = all.substring(startIndex, endIndex);
String str1 = s1.substring(0, s1.indexOf("."));
String str2 = s1.substring(str1.length() + 1);
String tm = str2;
if (str2.contains("A.")) {
int c1 = str2.indexOf("A.");
int c2 = str2.indexOf("B.");
String s11 = str2.substring(c1+2, c2);
System.out.println("A选项--" + s11);
tm = str2.substring(0, c1);
}
if (str2.contains("B.")) {
int c1 = str2.indexOf("B.");
int c2 = str2.indexOf("C.");
String s11 = str2.substring(c1+2, c2);
System.out.println("B选项--" + s11);
}
if (str2.contains("C.")) {
int c1 = str2.indexOf("C.");
int c2 = str2.indexOf("D.");
String s11 = str2.substring(c1+2, c2);
System.out.println("C选项--" + s11);
}
if (str2.contains("D.")) {
String C1 = str2.substring(0, str2.indexOf("D."));
String str22 = str2.substring(C1.length() + 2);
System.out.println("D选项--" + str22);
}
if(tm.contains("(")&&tm.contains(")")){
int c1 = tm.indexOf("(");
int c2 = tm.indexOf(")");
String s11 = tm.substring(c1+1, c2);
System.out.println("答案--" + s11.trim());
}
System.out.println("第"+i+"题目-----"+tm);
}
这里省略 自行百度
