⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 writeappend.java

📁 《JSP时尚编程百例》一例源代码81-100
💻 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 + -