Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class Main {
    private static final String DX_PATH = "D:\\android_sdk_for_studio\\build-tools\\22.0.1\\dx.bat";
    private static final String batchDir = System.getProperty("user.dir") + "\\batch\\";

    private static void buildDexFile(String projectDir) {
        StringBuffer command = new StringBuffer();
        command.append(DX_PATH).append(" --dex --output=").append(projectDir).append("\\bin\\classes.dex")
                .append(" ").append(projectDir).append("\\bin");
        buildExeBatchFiles(command.toString(), "3.bat");
    }

    private static void buildExeBatchFiles(String command, String fileName) {
        System.out.println(command);
        if (!new File(batchDir).exists()) {
            new File(batchDir).mkdirs();
        }
        String filePath = batchDir + fileName;
        try {
            writeFile(filePath, command);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static void writeFile(String filePath, String content) throws IOException {
        FileWriter fw = new FileWriter(filePath);
        PrintWriter out = new PrintWriter(fw);
        out.write(content);
        out.println();
        fw.close();
        out.close();
    }
}