有關java讀取文件,轉移
今天想通過數據庫轉移文件,想到java的流來進行處理。先讀取文件生成流再把流專業后,再將流中的數據生成文件。
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();
}
}
}




































posted on 2007-04-02 20:48 冷面閻羅 閱讀(2613) 評論(0) 編輯 收藏 所屬分類: java