English 中文(简体)
Java: 档案阅读器,按划界人划分 帮助
原标题:Java: File reader, String separator by delimiters Help

我正试图在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)

最佳回答

问题在于,如果可能不是旁边的旁观者,你会重新寻找下台。 我打破了逻辑,以便你能够从投入档案中逐行阅读。 如果一行的界线由您的辖区划分,则使用不同的扫描仪将内容分到辖区之间。 这部法典。 这在威信和电线(W/o wickets)内对许多条标有零。

public static void pLine (String FileName)throws IOException{
Scanner scanner = null;
try{
    scanner = new Scanner(new BufferedReader(new FileReader(FileName)));
    String line;
    ArrayList<String> inside;
    Scanner inner;
    int start;
    int end = 0;
    while (scanner.hasNextLine()) {
           line = scanner.nextLine();
           inside = new ArrayList<String>();
           start = line.indexOf("<<<", end);       
           end = line.indexOf(">>>", start+1);
           if (end > start) {
                inner = new Scanner(line.substring(start +3, end ));
                while (inner.hasNext()) {
                    inside.add(inner.next());
                }
            }
            System.out.println("inside : " + inside);
        }
    }
    catch (Throwable t) {
        t.printStackTrace();
    }
    finally {
        scanner.close();
    }
}
问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签