Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package games.coob.skywars.model;
- import java.io.*;
- public final class FileUtil {
- public static void copy(final File source, final File destination) throws IOException {
- if (source.isDirectory()) {
- if (!destination.exists()) {
- destination.mkdirs();
- }
- final String[] files = source.list();
- if (files == null)
- return;
- for (final String file : files) {
- final File newSource = new File(source, file);
- final File newDestination = new File(destination, file);
- copy(newSource, newDestination);
- }
- } else {
- final InputStream inputStream = new FileInputStream(source);
- final OutputStream outputStream = new FileOutputStream(destination);
- final byte[] buffer = new byte[1024];
- int length;
- while ((length = inputStream.read(buffer)) > 0) {
- outputStream.write(buffer, 0, length);
- }
- inputStream.close();
- outputStream.close();
- }
- }
- public static void delete(final File file) {
- if (file.isDirectory()) {
- final File[] files = file.listFiles();
- if (files == null)
- return;
- for (final File child : files) {
- delete(child);
- }
- }
- file.delete();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement