Fourteenth records of career

本文介绍了一个简单的Java程序,该程序展示了如何使用缓冲流进行文件复制,并提供了一个递归函数来遍历指定目录及其子目录下的所有文件。

December 9, 2016.

Today,the teacher has a problem .it involves all the knowledge before,i don't seemto know exactly how to do it ,but the problem is that that the knowledge is learned knowledge, i estimate that my previous knowledge is not strong enough,Usually go back after the real night to 1 am.

Now say that the hard work, the future can not see hope, then the road so far, how to do?

现在就说辛苦,对未来看不到希望,那以后的路还那么远那该怎么办??

        NOTES

//字符流不可用于操作图片  视频 音乐等文件


package testfileinput;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;


public class TestBuffered {
public static void main(String[] args) throws Exception {
FileOutputStream fos=new FileOutputStream("D:/12.jpg");  //写
FileInputStream fis=new FileInputStream("F:/12.jpg");   //读
BufferedOutputStream bos=new BufferedOutputStream(fos); //写
BufferedInputStream bis=new BufferedInputStream(fis);    //读
byte[] b=new byte[1024];
int a;
while((a=bis.read(b))!=-1){
bos.write(b, 0, a);
}
bos.close();
bis.close();
}
}





package file;
import java.io.File;//打印指定目录下的所有文件   包括文件夹里面的文件
public class hw_bianli_wj {
public static void getAllfiles(String path){
File file=new File(path);
//判断是否一个文件夹
if(file.isDirectory()){
//获取文件夹下的所有文件对象
File[] files=file.listFiles();
for (File fileson : files) {
if(fileson.isDirectory()){
//是文件  则调用自身
getAllfiles(fileson.getAbsolutePath());
}else{
System.out.println(fileson.getAbsolutePath());
}
}
}else{
System.out.println("这不是一个标准路径");
}
}
public static void main(String[] args) {
getAllfiles("F:/电视剧");
}
}

  This is notes, is also a life, and grow。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值