How to implement shell "ls -v" in java -
for example, run ls -v /tmp/chk
get:
ar1 ar20 ar100 pr1 pr20 pr100
but when use following groovy code:
new file("/tmp/chk").listfiles().sort().each { println it.name }
the result is:
ar1 ar100 ar20 pr1 pr100 pr20
how implement ls -v
algorithm same order in java or groovy
you should @ process builder. built kind of thing.
processbuilder processbuilder = new processbuilder("bash", "", "ls -v"); process p = pb.start(); bufferedreader reader = new bufferedreader(new inputstreamreader(p.getinputstream())); string readline; list<string> files = new arraylist<string>(); while ((readline = reader.readline()) != null) { files.add(readline); }
Comments
Post a Comment