public static void samples() throws IOException {

		// 1. 這是從檔中逐行讀入資料

		BufferedReader in = new BufferedReader(new FileReader("/home/ad/JAVA/foods.txt"));
		String s = "", s2 = "";
		while ((s = in.readLine()) != null)
			s2 += s + "\n";
		in.close();
		// 2. 這是從一個字串中逐個讀入位元組
		StringReader in1 = new StringReader(s2);
		int c;
		while ((c = in1.read()) != -1)
			System.out.print((char) c);

		// 3. 這是將讀取的字串寫入另個檔
		try {
			BufferedReader in2 = new BufferedReader(new StringReader(s2));
			PrintWriter out1 = new PrintWriter(new BufferedWriter(
					new FileWriter("D:\\IODemo.txt")));
			int lineCount = 1;
			while ((s = in2.readLine()) != null)
				out1.println(s);
			out1.close();
		} catch (EOFException e) {
			System.err.println("End of stream");
		}
	}