package com.teamcenter.rac.kernel;

import java.io.File;
import java.io.IOException;

public class Test {

	public void getPath() {

		String path = this.getClass().getProtectionDomain().getCodeSource()
				.getLocation().getPath();
		String exePath = path.substring(1, path.indexOf("com.connor.signoff"))
				.replace("/", "\\");
		File file = new File(path + "OpenCad.exe");

		if (file != null && file.exists()) {
			System.out.println("执行注册表修改");

		} else {
			System.out.println("不存在" + exePath + "文件");
		}
	}

	public static void main(String[] args) {

		String str = "item=|itemid|";
		if (str.endsWith("|")) {
			str = str.substring(0, str.lastIndexOf("|"));
			System.out.println(str);
		}
		String[] strS = str.split("=");
		System.out.println((strS == null || strS.length != 2) ? "" : strS[1]);

		Test test = new Test();
		test.getPath();

		String[] cmd = new String[] { "cmd.exe", "/C", "f:\\OpenCAD.exe" };
		try {
			Process process = Runtime.getRuntime().exec(cmd);
			process.destroy();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}