/**
* mysql启动器
* @author Administrator
*
*/
public class MysqlStrater {
public static void main(String[] args) {
//以管理员权限命令控制符c:/nircmd.exe Runtime.getRuntime().exec("c:/nircmd.exe elevate net start tomcat")
Process process = null;
try {
process = Runtime.getRuntime().exec("net start mysql");
} catch (IOException e) {
e.printStackTrace();
}
InputStream in = null;
in = process.getInputStream();
byte[] bs = new byte[1024];
List<Byte> listBytes = new ArrayList<Byte>();
try {
while ( in.read(bs) != -1) {
for (Byte b : bs) {
if( b != 0)
listBytes.add(b);
}
bs = new byte[1024];
}
bs = new byte[listBytes.size()];
for (int i = 0; i < listBytes.size(); i++) {
bs[i] = listBytes.get(i);
}
System.out.println(new String(bs,"GBK"));
} catch (UnsupportedEncodingException e) {
System.out.println("转码异常");
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}