?? 分行寫入數據.java
字號:
//將寫入文件的數據分行
import java.io.*;
public class 分行寫入數據
{
public static void main(String args[]) throws IOException
{ String path="F:\\java";
FileWriter fw=new FileWriter(path + "\\WriteData.txt");
BufferedWriter bw=new BufferedWriter(fw);
bw.write("大家好!");
bw.write("本書是《JSP編程技巧》。");
bw.newLine();//斷行
bw.write("請多多指教!");
bw.newLine();//斷行
bw.write("email: stride@sina.com");
bw.flush();//將數據更新至文件
fw.close();//關閉文件流
System.out.println("寫入文件內容為: ");
FileReader fr=new FileReader(path + "\\WriteData.txt");
BufferedReader br=new BufferedReader(fr);
String Line=br.readLine();//讀取一行數據
while(Line!=null)
{ System.out.println(Line + " ");
Line=br.readLine();
}
fr.close();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -