📄 writeappend.java
字号:
import java.io.*;
public class WriteAppend{
private String path;
private String something;
public WriteAppend(){
path = null;
something = "Default message";
} //constructor WriteAppend
//Mutator for the path property
public void setPath(String apath){
path = apath;
} // mutator setPath
//Accessor for the path property
public String getPath(){
return path;
}//accessor getPathClient
//Mutator for the something property
public void setSomething(String asomething){
something = asomething;
} // mutator setSomething
// Accessor for the something property
public String getSomething(){
return something;
}// accessor getSomething
//This method writes something to the path
public String writeSomething(){
try{
FileWriter theFile = new FileWriter(path,true);
PrintWriter out = new PrintWriter(theFile);
out.print(something + "\n");
out.close();
theFile.close();
return "";
} catch (IOException e){
return e.toString();
}
} // method writeSomething
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -