创建mobileconfig文件

public class MobileconfigUtil {
    public static String createMobileconfig(String path, String name) throws IOException {
        File file = new File(path);
        if (!file.exists()) {
            file.mkdirs();
        }
        String plistFile = ".mobileconfig";// 生成的文件名
        final String PLIST_PATH = path + plistFile; // 下载路径
        file = new File(PLIST_PATH);
        if (!file.exists()) {//检查是否已经创建
            try {
                file.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        String plist = "\n"
            + "\n"
            + "\n" + "\n" + "PayloadContent\n" + "\n" + "URL\n"
            + "https://blog.csdn.net/weixin_42286461\n"
            + "DeviceAttributes\n" + "\n" + "UDID\n" + "IMEI\n"
            + "ICCID\n" + "VERSION\n" + "PRODUCT\n" + "
\n"
            + "
\n" + "PayloadOrganization\n" + "blog.csdn\n"
            + "PayloadDisplayName\n" + "" + name+ "\n" + "PayloadVersion\n"
            + "1\n" + "PayloadUUID\n"
            + "3C4DC7D2-E475-3375-489C-0BB8D737A653\n" + "PayloadIdentifier\n"
            + "dev.skyfox.profile-service\n" + "PayloadDescription\n"
            + "本文件仅用来授权,不会真正安装到设备上!\n" + "PayloadType\n"
            + "Profile Service\n" + "
\n" + "
";
        try {
            FileOutputStream output = new FileOutputStream(file);
            OutputStreamWriter writer;
            writer = new OutputStreamWriter(output);
            writer.write(plist);
            writer.close();
            output.close();
        } catch (Exception e) {
            System.err.println("创建mobileconfig文件异常:" + e.getMessage());
        }
        return PLIST_PATH;
    }

    public static void main(String[] args) {
        try {
            MobileconfigUtil.createMobileconfig("D:/aaa",  "weixin_42286461的博客");
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

你可能感兴趣的:(功能代码)