我要将这段代码打印出来的东西写到文件里,不知道怎么操作,哪位大虾指教一下
String temp = "//==========================================================//\n"
+": GL4-GRQ-YJ-GP-CZ-%03dP%02dvfgt_fireby_%s\n"
+"执行lua函数,xbpg4dgModScript,%s";
for(int j=1;j<=100;j++)
{
for(int i=11;i<=16;i++)
{
System.out.println(String.format(temp, i,j,"lbtn_down", "showSusWindow"));
System.out.println(String.format(temp, i,j, "mouse_enter", "showModelName"));
System.out.println(String.format(temp, i,j, "mouse_leave", "setModelName"));
}
System.out.println("//==========================================================//\n"
+": GL4-GRQ-YJ-JX-CKvfgt_fireby_lbtn_down\n"
+"执行lua函数,xbpg4dgModScript,showSusWindow");
}
------解决方案--------------------
直接写文件就可以
------解决方案--------------------
执行的时候 用 > 重定向到一个文本文件里是最简单的方法
比如:java TestClass > TestClass.txt
------解决方案--------------------
public void do1(){
File f = new File("my.ini");
PrintStream out;
try {
out = new PrintStream(f);
System.setOut(out);
out.println("rrrrr");
out.println("xxx");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
------解决方案--------------------
在windows系统下,回车换行符号是"\r\n"
你的String temp = "//==========================================================//\n"
+": GL4-GRQ-YJ-GP-CZ-%03dP%02dvfgt_fireby_%s\n"
你取出来时自己换一下。