How to refresh directory using java -


i have java code in call shell script extract zip files. after script run, want copy extracted folder other location, when list contents of folder zip file , not extracted one. java code follows:

public class test {      public static void main(string[] args) throws ioexception, interruptedexception {         file file = new file("/home/a/");         file filenew = new file("/home/aaa/");         file filenew1 = new file("/home/aaa/script/");         file[] files = file.listfiles(new filenamefilter() {              @override             public boolean accept(file dir, string name) {              if(dir.exists()){                      return true;                 } else {                     return false;                 }             }         });         for(file file1:files){             system.out.println(file1.getname());             if(file1.getname().equals("app_dir"))             {                 system.out.println("inside app");             }             else if(file1.getname().endswith("zip"))             {                 file srcdir = new file(file+"/"+file1.getname());                 file destdir=new file("/home/aaa/script/*.zip");                 fileutils.copyfile(srcdir, destdir);             }              else if(file1.getname().endswith("tar"))             {                 file srcdir = new file(file+"/"+file1.getname());                 file destdir=new file("/home/aaa/script/*.tar");                 fileutils.copyfile(srcdir, destdir);             }              else             {             deletedir(file1);             }         }           try {              processbuilder pb = new processbuilder("/bin/bash","/home/aaa/myscript.sh");                 process p = pb.start();                 bufferedreader stdinput = new bufferedreader(new inputstreamreader(p.getinputstream()));                  bufferedreader stderror = new bufferedreader(new inputstreamreader(p.geterrorstream()));              } catch (ioexception e) {                  e.printstacktrace();             }         filenew1.canexecute();      file[] filesnew1 = filenew1.listfiles(new filenamefilter() {              @override             public boolean accept(file dir, string name) {              if(dir.exists()){                      return true;                 } else {                     return false;                 }             }         });          for(file file11:filesnew1){             system.out.println(file11.getname());             file f = new file(filenew+file.separator+"app_dir");             fileutils.copydirectory(f, file);         }        }     public static boolean deletedir(file dir) {         if (dir.isdirectory()) {             string[] children = dir.list();             (int = 0; < children.length; i++) {                 boolean success = deletedir(new file(dir, children[i]));                 if (!success) {                     return false;                 }             }         }         return dir.delete(); // directory empty , can deleted.     } } 

how refresh folder?


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -