/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
// 檔案對象建立
File f = new File("Exercise19_1");
if(f.exists()==false){
f.createNewFile();
}
// 這裡設計很差。如果原來的資料很多,每次都要拷貝。應該使用FlieWrite重寫
// 儲存已經存在的資料
Scanner input = new Scanner(f); //簡單的文本掃描器
StringBuffer sb = new StringBuffer("");
while (input.hasNext())
sb.append(input.next());
input.close(); //用完就關閉
PrintWriter pw = new PrintWriter(f); // 檔案被截取為o
pw.append(sb);
//追加100個隨機整數
Random rd = new Random();
for (int i = 0; i < 100; i++)
pw.append(rd.nextInt() + " ");