java - Scanning non-txt files with unspecified filename -
i want make tool 2 following things::
- open files not .txt can opened .txt , return them string. returns empty string @ moment.
- the filenames unknown, file extension @ end , the yyyymmdd number in front same, therefore i'd app scan every file in same folder (not same file twice, obviously). how can done?
that's i've got far. java code:
public string readfile(string filename) throws filenotfoundexception { scanner scanner = null; file file = new file(filename); string output = ""; try{ scanner = new scanner(file); }catch(filenotfoundexception e){ system.out.println("error: file " + filename + " not found!"); } while (scanner.hasnextline()){ output=output+scanner.nextline(); } return output; }
Comments
Post a Comment