3个回答
2013-07-17
展开全部
import java.io.*public class Demo{public static void main(String[] args) throws Exception{ File srcFile=new File("./srcDemo.txt");//源文件 File orgFile=new File("./orgDemo.txt");//目标文件 FileInputStream input=new FileInputStream(srcFile);//文件输入流 FileOutputStream output=new FileOutputStream(orgFile);//文件输出流 byte[] buf=new byte[4049];//缓冲 for(int size=0;size!=-1;size=input.read(buf)){ output.write(buf,0,size);//将缓冲区字节写入到输出流中 output.flush();//将输出流内容直接写到文件中 } output.close();//关闭流 input.close();}}
2013-07-17
展开全部
package test;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class Test1 {
public static void main(String[] args) {
File file=new File("E:/《传说》.mp3");
FileInputStream fread;
BufferedInputStream reader=null;
BufferedOutputStream write=null;
try {
fread = new FileInputStream(file);
reader=new BufferedInputStream(fread);
String str=null;
write=new BufferedOutputStream(new FileOutputStream(new File("F:\\123.mp3")));
byte b[]=new byte[1024];
int i=0;
while((i=reader.read(b))!=-1){
write.write(b);
//System.out.println(b);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally{
try {
write.close();
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}}
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class Test1 {
public static void main(String[] args) {
File file=new File("E:/《传说》.mp3");
FileInputStream fread;
BufferedInputStream reader=null;
BufferedOutputStream write=null;
try {
fread = new FileInputStream(file);
reader=new BufferedInputStream(fread);
String str=null;
write=new BufferedOutputStream(new FileOutputStream(new File("F:\\123.mp3")));
byte b[]=new byte[1024];
int i=0;
while((i=reader.read(b))!=-1){
write.write(b);
//System.out.println(b);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally{
try {
write.close();
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-07-17
展开全部
其实思路 就是用FileInputStream读文件,FileOutputStream写文件,读一行,写一行,不久复制了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询