有关FileInputStream、FileOutputStream和BufferedInputStream、BufferedOutputStream的问题,请高手解答! 同时打开多个写入流对象,同时写入读出的数据吧! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不是呀,每次打开一个输入流,读完后就关闭,然后打开一个输出流,写到文件里。每次都这样。 //--not wrote by meprivate static void copyfile(String str,String str1) throws FileNotFoundException {try {File file=new File(str);InputStream is=null;OutputStream os=null;byte[] b;File f=new File(str1);if(!file.isDirectory()) { is=new FileInputStream(str); b=new byte[is.available()]; is.read(b); os=new FileOutputStream(str1); os.write(b); is.close(); os.close(); return;} else if(!f.exists()) f.mkdirs();File[] filename=file.listFiles();for(int i=0;i<filename.length;i++) { copyfile(filename[i].getAbsolutePath(),str1+"/"+filename[i].getName());}} catch(IOException ex) {filecopycount++;System.out.println("filecopycount:"+String.valueOf(filecopycount));if(filecopycount<=5)copyfile(str,str1);System.err.println("err:"+ex.toString());}} 我已经发现问题了,给分了。 vector问题 为什么还要进行转换? 大家都来想想,用最简单的方法做 请问如何画2象素的曲线? treemap或者hashmap的怪问题,快受不了 图形资源 J2SE初学者的问题:关于被导入类? JAVA开发中的B/S方式,C/S方式到底是什么? 请教 ,如何做JBUILDER项目的安装程序,如何在其中加入所用到的包,120分献上。 请问:java上,jRadioButtonod的事件是什么? 求解答,在牛客网上跑java代码提示数组越界非法访问 用java实现作用(画图,线,保存,色彩。。。 初学者报道(一)
private static void copyfile(String str,String str1) throws FileNotFoundException {
try {
File file=new File(str);
InputStream is=null;
OutputStream os=null;
byte[] b;
File f=new File(str1);
if(!file.isDirectory()) {
is=new FileInputStream(str);
b=new byte[is.available()];
is.read(b);
os=new FileOutputStream(str1);
os.write(b);
is.close();
os.close();
return;
} else if(!f.exists())
f.mkdirs();
File[] filename=file.listFiles();
for(int i=0;i<filename.length;i++) {
copyfile(filename[i].getAbsolutePath(),str1+"/"+filename[i].getName());
}
} catch(IOException ex) {
filecopycount++;
System.out.println("filecopycount:"+String.valueOf(filecopycount));
if(filecopycount<=5)
copyfile(str,str1);
System.err.println("err:"+ex.toString());
}
}