eclipse - Too many files open in system when outputting to a txt file in Java -
this question has reply here:
too many open files: how many open, are, , how many can jvm open 3 answersi trying create programme goes through text file , counts word usage in java, using eclipse. programme works, want save output values text file. using bit of code that:
printstream out = new printstream(new fileoutputstream("output.txt")); system.setout(out); i have used
throws filenotfoundexception to rid of file not found exception.
when run program, error says
exception in thread "main" java.io.filenotfoundexception: output.txt (too many open files in system) @ java.io.fileoutputstream.open(native method) @ java.io.fileoutputstream.<init>(fileoutputstream.java:221) @ java.io.fileoutputstream.<init>(fileoutputstream.java:110) @ ngram.hashmapfun.main(hashmapfun.java:66) i made output.txt file in java project, don't know why programme can't find it. output hashmap.
how prepare this?
thanks in advance.
i have used throws filenotfoundexception rid of file not found exception.
listen, using throws don't rid of excetion.
you need grab thrown exception. long there exception cannot go on point, until skip stage using conditional statement.
try { // code here } grab (exception e) { // message here } unix os , such other os limit each process number of files loaded @ time. so, think you're using reader or scanner need close them.
use
scanner.close(); i unaware of scanner of filereader code. so, can replate that. 1 time you're using code, file whom you're done working closed , link closed. enabling open new file.
java eclipse filenotfoundexception
No comments:
Post a Comment