Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void copy(File source, File target) throws IOException
- {
- if (source.isDirectory())
- {
- if (!target.exists())
- target.mkdir();
- String[] children = source.list();
- for (int i = 0; i < children.length; i++)
- copy(new File(source, children[i]), new File(target, children[i]));
- }
- else
- {
- InputStream in = new FileInputStream(source);
- OutputStream out = new FileOutputStream(target);
- byte[] buf = new byte[1024];
- int len;
- while ((len = in.read(buf)) > 0)
- out.write(buf, 0, len);
- in.close();
- out.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment