简体   繁体   中英

Scanning large text file into NetBeans

For some reason, NetBeans only reads in the first 1000 lines into the String array, and the rest of the array is left null. If I run the code in Eclipse it works. I've tried increasing the heap size, but it hasn't worked. Here is the code for reference.

private String[] loadDictionary() throws FileNotFoundException
{
    String[] darr = new String[10000];
    Scanner sc = new Scanner(new File("Dictionary"));
    for(int i = 0; i<10000; i++)    
    {
        if(sc.hasNext())
            darr[i] = sc.next();
    }
    sc.close();
    return darr;
}

尝试使用hasNextLine()nextLine()实例化。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM