IO流
来源:互联网 发布:js作用域链和原型链 编辑:程序博客网 时间:2024/06/06 16:39
**
IO流
**
字节IO流
File file = new File("d://b.txt"); File file1=new File("d://a.txt"); if(!file.exists()){ try { file.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } try { FileInputStream fis=new FileInputStream(file1); FileOutputStream fos=new FileOutputStream(file); byte []array=new byte[1024]; int i=fis.read(array); while(i!=-1){ fos.write(array, 0, i); i=fis.read(array); } fis.close(); fos.flush(); fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
字节IO流字符IO流和缓冲流
File file = new File("d://b.txt"); File file1=new File("d://a.txt"); if(!file.exists()){ try { file.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } try { FileInputStream fis=new FileInputStream(file1); FileOutputStream fos=new FileOutputStream(file); byte []array=new byte[1024]; int i=fis.read(array); while(i!=-1){ fos.write(array, 0, i); i=fis.read(array); } fis.close(); fos.flush(); fos.close(); //OutputStreamWriter osw=new OutputStreamWriter(fos); //BufferedWriter bw=new BufferedWriter(osw); //String words="asdasdas"; // bw.write(words); // bw.flush(); // bw.close(); // fos.close(); // osw.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } // try { // FileInputStream fis = new FileInputStream(file);// 这个读字节//InputStreamReader isr = new InputStreamReader(fis);// 这个读字符//BufferedReader br = new BufferedReader(isr);// 这个读行//String string = br.readLine(); // while (string != null) {// System.out.println(string);// string = br.readLine();// }// fis.close();// isr.close();// br.close();// } catch (FileNotFoundException e) {// e.printStackTrace();// } catch (IOException e) {// e.printStackTrace();// } }
0 0
- 【IO流】IO框架
- IO流呀IO流
- 字符IO&数据流IO&对象流IO
- io流
- io流
- IO流
- IO流
- IO 流
- IO流
- io流
- IO流
- io流
- IO流
- IO流
- IO流
- IO流
- IO流
- IO流
- jquery下的ajax
- 二叉树的基本使用
- SSM的maven项目
- window上安装 MongoDB PHP扩展
- Altium Designer静态标注的bug
- IO流
- 中文GCC
- 哈理工2015暑假集训 zoj 2975 Kinds of Fuwas
- 像素、分辨率、屏幕大小(屏幕适配必看)
- Oracle RAC安装过程中碰到的“坑”和关键点(二)
- Java学习笔记---一些关键字的使用
- Windows平台安装Beautiful Soup
- 与某深聊过之后
- hihoCoder 1080 更为复杂的买卖房屋姿势(区间更新)