writetofile.java
来自「大量jsp编程使用例子」· Java 代码 · 共 38 行
JAVA
38 行
import java.io.*;
public class WriteToFile{
private String path;
private String something;
public WriteToFile() {
path = null;
something = "Default message";
}
// Mutator for the path property
public void setPath(String apath){
path = apath;
}
// Accessor for the path property
public String getPath() {
return path;
}
// Mutator for the something property
public void setSomething(String asomething){
something = asomething;
}
// Accessor for the something property
public String getSomething(){
return something;
}
// This method writes something to the path
public String writeSomething(){
try{
File f = new File(path);
PrintWriter out = new PrintWriter(new FileWriter(f));
out.print(this.getSomething() + "\n");
out.close();
return "Alles ist Gut.";
} catch (IOException e){
return e.toString();
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?