六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 43|回复: 0

有关java读取文件,转移

[复制链接]

升级  17.67%

75

主题

75

主题

75

主题

举人

Rank: 3Rank: 3

积分
253
 楼主| 发表于 2013-1-27 04:43:46 | 显示全部楼层 |阅读模式
今天想通过数据库转移文件,想到java的流来进行处理。先读取文件生成流再把流专业后,再将流中的数据生成文件。
<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee;">package word;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;

public class TestDoc {
    
public static void main(String args[]) {
          
int   bytesum=0;   
          
int   byteread=0;     
          InputStream inStream;
        
try {
            inStream 
= new   FileInputStream("c:/1.xls");
              FileOutputStream   fs
=new   FileOutputStream("d:/aaa.xls");byte[]     buffer   =new     byte[1444];   
              
while   ((byteread=inStream.read(buffer))!=-1)   
                
{   
                    bytesum
+=byteread;   
                    fs.write(buffer,
0,byteread);   
                }
     
              inStream.close(); 
        }
 catch (Exception e) {
            e.printStackTrace();
        }
   
 
    }

}
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表