Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package themescleaner;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.nio.channels.FileChannel;
- public class Main {
- private static final String VERSION_NAME = "0.1";
- private static final String ROOT = "c:/AChep/themecleanup/";
- private static final String RESOURCES = "resources";
- private static final String THEMED = "themed";
- private static final String DELETED = "deleted";
- private static final String INPUT = "input";
- public static void main(String[] args) {
- logln(3);
- logln("Program:");
- logln(" ThemeCleaner " + VERSION_NAME);
- logln("Contact:");
- logln(" 2012 (C) AChep@xda");
- logln(" <artemchep@gmail.com>");
- logln(1);
- log("Preparing folders... ");
- /*
- for (int i = 0; i < 20000; i++) {
- File test = new File(ROOT + RESOURCES + "/android_" + i + ".xml");
- try {
- test.createNewFile();
- } catch (IOException e) {
- logln("E: Error copying file...");
- }
- }
- */
- final File[] files = new File(ROOT + INPUT).listFiles();
- final File themed = new File(ROOT + THEMED);
- themed.delete();
- themed.mkdir();
- final File deleted = new File(ROOT + DELETED);
- deleted.delete();
- deleted.mkdir();
- logln("Successfully.");
- log("Comparing files... ");
- for (int i = 0; i < files.length; i++) {
- File res = new File(ROOT + RESOURCES + "/" + files[i].getName());
- try {
- copyFile(files[i], new File(ROOT + (res.exists() && res.length() != files[i].length() ? THEMED : DELETED) + "/" + files[i].getName()));
- } catch (IOException e) {
- logln("E: Error copying file...");
- }
- }
- logln("Successfully.");
- }
- public static void copyFile(File sourceFile, File destFile) throws IOException {
- if (!destFile.exists()) {
- destFile.createNewFile();
- }
- FileChannel source = null;
- FileChannel destination = null;
- try {
- source = new FileInputStream(sourceFile).getChannel();
- destination = new FileOutputStream(destFile).getChannel();
- destination.transferFrom(source, 0, source.size());
- } finally {
- if (source != null) {
- source.close();
- }
- if (destination != null) {
- destination.close();
- }
- }
- }
- private static void log(String str) {
- System.out.print(str);
- }
- private static void logln(int number) {
- if (number > 1) {
- logln(number - 1);
- }
- logln("");
- }
- private static void logln(String str) {
- System.out.println(str);
- }
- }
Add Comment
Please, Sign In to add comment