Hello, i am newbie in this forum, forgive me in case if i give my query in wrong place,
My query is i have a directory consists of few files with different memory size, now i want to move the files of les than 10mb toanother directory path
i have written the code, please lemme know whats wrong there in it, i am getting an exception ..Exception in thread "main" java.io.FileNotFoundException: /home/dev06/temporaryfolder/home/dev06/sourcefolder/b (No such file or directory)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.j ava:212)
at java.io.FileOutputStream.<init>(FileOutputStream.j ava:104)
at App.checking(App.java:22)
at main.main(main.java:6)
my i ve writen the code .. i do have the files name a, b
public class App {
int count = 0;
File source = new File("/home/dev06/sourcefolder/");
File destination = new File("/home/dev06/temporaryfolder");
public void checking() throws IOException {
for (File files : source.listFiles()) {
if (files.isFile()) {
// count++;
long filesize = files.length();
if (filesize > 10) {
//System.out.println(files.getName() + " and the size is "
// + filesize + "bytes");
InputStream in = new FileInputStream(files);
OutputStream out = new FileOutputStream(destination + "/"
+ files);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
}
}
}
//System.out.println("no of files " + count);
}
}
Thank you