- /*
- 需求:将图片文件中的数据存储到另一个文件中。
- 源:FileInputStream
- 目的:FileOutputStream
- */
- import java.io.*;
- class IOTest2
- {
- public static void main(String[] args)
- {
- BufferedReader br =null;
- BufferedWriter bw =null;
- try
- {
- br = new BufferedReader(new InputStreamReader(new FileInputStream("readLine原理图.jpg")));
- bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("readLine.jpg")));
- String s = null;
- while ((s=br.readLine())!=null)
- {
- bw.write(s);
- bw.newLine();
- bw.flush();
- }
-
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- finally
- {
- try
- {
- if (br!=null)
- {
- br.close();
- }
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- try
- {
- if (bw!=null)
- {
- bw.close();
- }
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- }
- }
- }
复制代码
|
|