我正试图在java建立一个预案人,在来源法中读。 我试图把这部法典全文读到一处。
问题:我如何在自己类型的阵列清单中添加斜体;加固;加固;和特;加固;和。
public class processLines {
public void pLine (String FileName)throws IOException{
Scanner scanner = null;
try{
scanner = new Scanner(new BufferedReader(new FileReader(FileName)));
while (scanner.hasNext()) {
String Line = "";
String LineB = "";
String LineC = "";
ArrayList<String> inside = new ArrayList<String>();
Line = Line + scanner.next()+ " ";
System.out.println("outside token: "+ Line);
StringTokenizer token = new StringTokenizer(Line);
while(token.hasMoreTokens()&& token.nextToken() != null){
LineB = Line;
if(LineB.contains("<<<")){
if(!LineB.contains(">>>") ){
LineC = LineC + scanner.next()+ " ";
inside.add(LineC);
System.out.println("LineC: " + LineC);
System.out.print(inside);
iii
if(scanner.next(">>>") != null){
Line = scanner.next();
System.out.println("Line INside:" + Line);
iii
iii
iii
iii
iii
finally {
if (scanner != null) {
scanner.close();
iii
iii
iii
iii
文本档案来源包括“Mo <<<Moarry Curly >>>Larry”,所有一条线。 如果在“斜线”中只有一个名字,“再设计”、“再设计”、“得”、“和”等,但当我增加一个错误时,该法典就发挥了作用。
发出错误信息: 页: 1
outside token: <<< LineC: Mo [Mo ]Exception in thread "main" java.util.InputMismatchException at java.util.Scanner.throwFor(Unknown Source) at java.util.Scanner.next(Unknown Source) at java.util.Scanner.next(Unknown Source) at processLines.pLine(processLines.java:26) at proProcess.main(proProcess.java:14)