📄 cheddarrunner.java
字号:
package com.thalesgroup.cheddar.MARTE2cheddar.tools;
import java.io.InputStream;
import org.eclipse.core.resources.IFile;
/**
* Utility class for running Cheddar.
* Requires that cheddar directory is in the %PATH%
* <copyright>
* Thales MARTE to Cheddar (Copyright (c) THALES 2007 All rights reserved) is free software; you can redistribute itand/or modify
* it under the terms of the Eclipse Public License as published in http://www.eclipse.org/legal/epl-v10.html
*
* Thales MARTE to Cheddar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Eclipse Public License for more details.
* </copyright>
* @author Nicolas Vienne
*
*/
public class CheddarRunner {
/**
* Launches Cheddar with the specified file as parameter
* @param file IFile to be launched in Cheddar
*/
public static void Exec(IFile file){
if(file != null) {
try {
// WARNING : CHEDDAR MUST BE IN %PATH%
String[] cmd = {"cmd.exe", "/c", "cheddar.exe", file.getLocation().toString()};
Process p = Runtime.getRuntime().exec(cmd);
InputStream is = p.getInputStream();
String r = "";
int c;
do {
c = is.read();
if(c != 1) {
r += (char)c;
}
} while( c != -1);
r = r.substring(0, r.length()-1);
String[] rs = r.split("\n");
r = "";
for(int i=6; i< rs.length; i++) r += rs[i]+"\n";
if(r != "") {
r = r.substring(0, r.length()-1);
System.out.println("Cheddar said :");
System.out.println(r);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -