java - Combining text file using method -


hi trying write program assignment takes 4 separate text files using method, combines them one. wondering if me find out wrong code. when try run error reading following:

"exception in thread "main" java.io.filenotfoundexception: wonder1.txt (the system cannot find file specified)     @ java.io.fileinputstream.open(native method)     @ java.io.fileinputstream.<init>(unknown source)     @ java.util.scanner.<init>(unknown source)     @ asig5.combinefile(asig5.java:26)     @ asig5.main(asig5.java:17) " 

code:

import java.io.ioexception; import java.io.printwriter; import java.io.file;  public class asig5 {      public static void main(string[] args) throws filenotfoundexception {          printwriter newtext = new printwriter("wonder5.txt");         file f0 = new file("wonder1.txt");         file f1 = new file("wonder2.txt");         file f2 = new file("wonder3.txt");         file f3 = new file("wonder4.txt");         combinefile(f0, newtext);         combinefile(f1, newtext);         combinefile(f2, newtext);         combinefile(f3, newtext);          newtext.close();      }      public static void combinefile(file f0, printwriter output) throws filenotfoundexception {         scanner input = new scanner(f0);         while (input.hasnext()) {              string part1 = input.nextline();             system.out.println(part1);             output.print(part1);         }      } } 

when write new file("wonder1.txt") means if project location ~/folder/myproject, file's full path ~/folder/myproject/wonder1.txt.

you need provide full path file or put files @ root of project folder.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -