writeappend.java

来自「大量jsp编程使用例子」· Java 代码 · 共 39 行

JAVA
39
字号
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 + =
减小字号Ctrl + -
显示快捷键?