Java how to get file without full name -
i need file directory downloaded application in part of app, name of file creating dynamically. mean query_ , digits, fe. query_21212121212, query_22412221. need absolute file path, sth c:/dir/query_*. how that?
if know path files reside, can create directorystream , files in it.
see https://docs.oracle.com/javase/tutorial/essential/io/dirs.html#glob
example (from link above):
path dir = ...; try (directorystream<path> stream =      files.newdirectorystream(dir, "*.{java,class,jar}")) { //<--- change glob                                                              //fit name pattern.     (path entry: stream) {         system.out.println(entry.getfilename());     } } catch (ioexception x) {     // ioexception can never thrown iteration.     // in snippet, can // thrown newdirectorystream.     system.err.println(x); }   about globs: https://docs.oracle.com/javase/tutorial/essential/io/fileops.html#glob
so in case "query_*". use special extension or no extension @ all? if .txt glob should "query_[0-9]+.txt".
Comments
Post a Comment