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

📄 writetofile.java

📁 《JSP时尚编程百例》一例源代码81-100
💻 JAVA
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -