1

Because many method which i have used does this, but they ll ultimately end up in copying each file by it conetents? as i have text files with lots of contents i will be a slow process?

GuruKulki
  • 25,776
  • 50
  • 140
  • 201

3 Answers3

2

You could use FileUtils from Apache Commons IO?

toolkit
  • 49,809
  • 17
  • 109
  • 135
  • thanks but if i want to apply a filter, fileutils will copy only the filter type of files. while i want the other way. ie except the filter type copy all. – GuruKulki Jan 06 '10 at 14:51
  • Just implement a wrapper that inverts the filter – Jens Schauder Jan 06 '10 at 14:59
  • Important note: as I pointed out lo so many moons ago, the version of Apache Commons IO that's in the svn repository uses Java's NIO to copy files and directories, which will give most users a *significant* IO boost. I have no clue why this hasn't made it out to the release stage yet, but I use it in any of my file/directory copying code, and it's much better. http://stackoverflow.com/questions/106770/standard-concise-way-to-copy-a-file-in-java/106807#106807 – delfuego Jan 06 '10 at 18:05
2

I would recommend something like FileUtils from Apache Commons IO.

miku
  • 181,842
  • 47
  • 306
  • 310
0

I'm not sure if you want to move a directory, or or the files in it, but could you use renameTo and something like...

File origDir = new File("OrigDir");
File newDir = new File("NewDir");
origDir.renameTo(new File(newDir, origDir.getName()));
Miles D
  • 7,960
  • 5
  • 34
  • 35