zoukankan      html  css  js  c++  java
  • 本地文件的copy复制

     1 package testio;
     2 
     3 import java.io.BufferedReader;
     4 import java.io.BufferedWriter;
     5 import java.io.File;
     6 import java.io.FileInputStream;
     7 import java.io.FileOutputStream;
     8 import java.io.IOException;
     9 import java.io.InputStreamReader;
    10 import java.io.OutputStreamWriter;
    11 
    12 public class Copy {
    13     public static void main(String[] args) {
    14         File file1 = new File("d:/folder01/file09.txt");
    15         File file2 = new File("d:/folder01/file10.txt");
    16         FileInputStream fis = null;
    17         InputStreamReader isr = null;
    18         BufferedReader br = null;
    19         BufferedWriter bw = null;
    20         OutputStreamWriter osw = null;
    21         FileOutputStream fos = null;
    22         try {
    23             fis = new FileInputStream(file1);
    24             isr = new InputStreamReader(fis);
    25             br = new BufferedReader(isr);
    26 
    27             fos = new FileOutputStream(file2);
    28             osw = new OutputStreamWriter(fos);
    29             bw = new BufferedWriter(osw);
    30             int data;
    31             while ((data = br.read()) != -1) {
    32                 bw.write(data);
    33                 bw.flush();
    34             }
    35         } catch (Exception e) {
    36             // TODO Auto-generated catch block
    37             e.printStackTrace();
    38         } finally {
    39             if (fis != null) {
    40 
    41                 try {
    42                     fis.close();
    43                     isr.close();
    44                     br.close();
    45                     fos.close();
    46                     osw.close();
    47                     bw.close();
    48                 } catch (IOException e) {
    49                     // TODO Auto-generated catch block
    50                     e.printStackTrace();
    51                 }
    52             }
    53         }
    54     }
    55 }
  • 相关阅读:
    Jenkins安装后,安装插件失败。报错SunCertPathBuilderException
    计算机网络
    abaqus
    品优购
    html5 css3
    css定位
    元素的显示与隐藏 / 精灵图
    学成在线案例
    css(3)
    css(2)
  • 原文地址:https://www.cnblogs.com/String-likainian/p/5855202.html
Copyright © 2011-2022 走看看