java - Problems with importing a document and changing the strings of the document and outputting the new strings in a new .txt document -


it should output new .txt document, when does, outputs original document. error message:

exception in thread "main" java.lang.error: unresolved compilation problem:      method must return result of type string 

if comment out return "ok", otherwise creates new document same details original document.

what cause?

public static string replace(string filename) {     try {         scanner file = new scanner(new file(filename));         system.out.println(file);         stringbuilder b = new stringbuilder();         string s = "";         while(file.hasnextline()){              s = file.nextline();               if (s.equals("x")) {                 s = "0";                 b.append(s).append(system.getproperty("line.separator"));             } else {                 b.append(s).append(system.getproperty("line.separator"));             }          }         try (printstream out = new printstream(new fileoutputstream("test1,1.txt"))) {             out.print(b);             out.close();         } catch (ioexception e) {          }      } catch (exception e) {         system.out.println("problem reading file.");     }     return "ok"; } 


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -