上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 31 下一页
摘要: FileInputStream fis = new FileInputStream ("王大.jpg"); //创建输入流对象,关联王大.jpg FileOutputStream fos = new FileOutputStream ("copy.jpg");//创建输出流对象,关联copy.jpg 阅读全文
posted @ 2020-06-01 21:45 一块 阅读(153) 评论(0) 推荐(0) 编辑
摘要: FileOutputStream fos = new FileOutputStream ("test.txt",true); //如果想追加就在第二个参数传true fos.write(97); fos.write(98); fos.close(); 阅读全文
posted @ 2020-06-01 21:34 一块 阅读(373) 评论(0) 推荐(0) 编辑
摘要: FileOutputStream fos = new FileOutputStream ("test.txt"); //创建字节输出流对象,如果没有就自动创建一个,如果有这个文件就会先将这个文件清空。 fos.write(97); //虽然写出的是一个int数,但是到文件上的是一个字节,会自动去除前 阅读全文
posted @ 2020-06-01 21:21 一块 阅读(131) 评论(0) 推荐(0) 编辑
摘要: FileInputStream fis = new FileInputStream ("teat.txt"); //创建流对象 int x = fis.read(); //从硬盘上读取一个字节(每读一次指针向后一次) fis.close(); //关流释放资源 阅读全文
posted @ 2020-06-01 21:10 一块 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 概念: IO流用来处理设备之间的数据传输。 Java对数据的操作是通过流的方式。 JAVA用于操作流的类都在IO包中。 流按流向分为两种:输入流、输出流。 流按操作类型分为两种: 字节流:字节流可以操作任何数据,因为在计算机中任何数据都是以字节的形式存储的。 字符流:字符流只能操作纯字符数据,比较方 阅读全文
posted @ 2020-05-28 22:26 一块 阅读(382) 评论(0) 推荐(0) 编辑
摘要: 过滤器接口: public interface FilenameFilter { boolean accept(File dir, String name); } 使用: File dir = new File("E:\\"); String[] arr = dir.list(new Filenam 阅读全文
posted @ 2020-05-28 22:09 一块 阅读(230) 评论(0) 推荐(0) 编辑
摘要: 需求:判断E盘目录下是否有后缀名为.jpg的文件,如果有就输出该文件名称。 File dir = new File("E:\\"); 方法一: String [] arr = dir.list(); //获取e盘下所有的文件或文件夹 for(String string : arr){ if(stri 阅读全文
posted @ 2020-05-28 21:28 一块 阅读(425) 评论(0) 推荐(0) 编辑
摘要: file.getAbsolutePath(); //获取文件的绝对路径 file.getPath(); //获取路径(构造方法里传什么路径就获取到什么路径) file.getName(); //获取文件或文件夹的名称 file.length(); //获取文件的长度 字节数。 file.lastMo 阅读全文
posted @ 2020-05-27 22:39 一块 阅读(261) 评论(0) 推荐(0) 编辑
摘要: file.exists(); //判断文件是否存在。 file.isFile(); //判断是否是文件。 file.isDirectory(); //判断是否是文件夹。 file.setReadable(false); //将文件设置为不可读的 file.canRead(); //判断文件是否可读。 阅读全文
posted @ 2020-05-27 22:19 一块 阅读(415) 评论(0) 推荐(0) 编辑
摘要: public boolean createNewFile(); //创建文件,如果存在这样的文件,就不创建了,返回值为布尔类型。 public boolean mkdir(); //创建文件夹 如果存在这样的文件夹,就不创建了,返回值为布尔类型。 public boolean mkdirs(); / 阅读全文
posted @ 2020-05-27 22:10 一块 阅读(611) 评论(0) 推荐(0) 编辑
上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 31 下一页