试试看:)
这种解决方案的优点是,您有了临时文件,调试起来更加容易!
String lineIndex="21";String line="2";String currentBid="102";File temp = File.createTempFile("temp-sh", ".sh");FileWriter fw = new FileWriter(temp);fw.write("#!/bin/bashn");fw.write("sed -i '"+lineIndex+"s/"+line+"/"+currentBid+"/g' data/jsp/items.xmln");fw.close();System.out.println(". "+temp.getAbsolutePath());Runtime.getRuntime().exec(". "+temp.getAbsolutePath());


