1

This is my code. Basically, I want to filter the filenames and move it in the same folder

String path = System.getProperty("user.dir");
    File file = new File(path);
    String[] content = file.list();
     FilenameFilter textFilter = new FilenameFilter() {
        public boolean accept(File dir, String name) {
                        String lowercaseName = name.toLowerCase();
                         if (lowercaseName.startsWith("to1.")){
                              File d = new File("TO1");
                              d.mkdir();

I wanted to move all the files with the prefix with TO1. into the same folder somehow I don't know how to implement the move in java. what can you guys recommend?

Sumsuddin Shojib
  • 3,583
  • 3
  • 26
  • 45
  • That doesn't look like all of the code. – Jacob G. Jan 28 '18 at 04:34
  • i've checked that out but, is it posible to use that under the filter? – Vincent Ray Bermejo Jan 28 '18 at 04:37
  • 1
    1) For better help sooner, post a [MCVE] or [Short, Self Contained, Correct Example](http://www.sscce.org/). 2) Tip: Add @VincentRayBermejo (or whoever, the `@` is important) to *notify* the person of a new comment. 3) Use a logical and consistent form of indenting code lines and blocks. The indentation is intended to make the flow of the code easier to follow! – Andrew Thompson Jan 28 '18 at 04:46
  • Bear in mind that you probably have more options for doing this in Java 8 and newer thanks to `Path.find`, streams, and lambdas. – Powerlord Jan 28 '18 at 04:50
  • Sorry, `java.nio.files`'s `Files.find` . Lost track of which one has static methods in it. – Powerlord Jan 28 '18 at 05:02

0 Answers0