?? writefile.java
字號:
package com.chapter4;
import java.io.*;
public class WriteFile
{
//類成員變量
private String path;
private String content;
//初始化
public WriteFile()
{
this.path = "";
this.content = "default content";
}
//設置文件路徑
public void setPath(String path)
{
this.path = path;
}
//得到文件路徑
public String getPath()
{
return this.path;
}
//獲取所要寫入的內容
public void setContent(String content)
{
this.content = content;
}
//設置所要寫入的內容
public String getContent()
{
return this.content;
}
//寫入字符串到文件中
public int writeContent()
{
int r = 0;
try
{
File fObj = new File(this.path);
PrintWriter out = new PrintWriter(new FileWriter(fObj));
out.print(this.getContent());
out.close();
}
catch (IOException e)
{
r = -1;
}
return r;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -