大数据文件上传

 public String readFile() throws IOException
    {
        File rFile = new File("c:/jdk1.5.0_14.rar");
        File wFile = new File("e:/jdk1.5.0_16.rar");
        try {
            FileInputStream  iReader = new FileInputStream(rFile);
            FileOutputStream oWriter =  new FileOutputStream(wFile);
            int off = 0;
            int length = 1024;
            byte[] buff = new byte[length];

           // 注意:读出1024字节写入1024字节
            while((off=iReader.read(buff,0,length)) !=-1)
            {
                oWriter.write(buff);
            }
           oWriter.flush();
           oWriter.close();
           iReader.close();
        } catch (FileNotFoundException ex) {
            Logger.getLogger(FileIO.class.getName()).log(Level.SEVERE, null, ex);
        }
        return "success";
    }

猜你喜欢

转载自blog.csdn.net/QWERT520/article/details/6053268
今日推荐