- 浏览: 1241607 次
- 性别:
- 来自: 深圳
-
文章分类
- 全部博客 (718)
- HTML (13)
- JS基础 (23)
- JS应用 (40)
- AJAX (6)
- JSP相关 (12)
- JAVA基础 (52)
- JAVA应用 (74)
- APPLET (11)
- SWING\RCP (2)
- JAVA反射 (6)
- 设计模式 (26)
- 数据库设计 (20)
- Struts (35)
- Struts2 (12)
- Spring (22)
- Hibernate (45)
- Ibatis (18)
- mybatis (3)
- SSH (8)
- UML (5)
- WebService (3)
- XML (16)
- Log4j (7)
- WEB容器 (26)
- 数据结构 (36)
- Linux (34)
- Ruby on Rails (1)
- 其它技术 (27)
- IDE配置 (15)
- 项目实战 (2)
- Oracle (69)
- JAVA报表 (7)
- Android学习 (2)
- 博客链接 (1)
- 网络基础 (1)
- WEB集群 (1)
- .Net开发 (11)
- PB (4)
- 系统构建 (15)
最新评论
-
jnjeC:
牛逼啊哥们,讲得太好了
Maven仓库理解、如何引入本地包、Maven多种方式打可执行jar包 -
九尾狐的yi巴:
很好 感谢!
Itext中文处理(更新版) -
luweifeng1983:
有用的,重启一下嘛。
设置eclipse外部修改文件后自动刷新 -
Master-Gao:
设置了也不管用,怎么破呢?
设置eclipse外部修改文件后自动刷新 -
aigo_h:
锋子还有时间写博客,还是很闲哈!
Add directory entries问题
JAVA文件操作相关:
- package com.bytecode.openexcel.util;
- import java.io.*;
- public class FileOperate {
- public FileOperate() {
- }
- /**
- * 新建目录
- *
- * @param folderPath
- * String 如 c:/fqf
- * @return boolean
- */
- public void newFolder(String folderPath) {
- try {
- String filePath = folderPath;
- filePath = filePath.toString();
- java.io.File myFilePath = new java.io.File(filePath);
- if (!myFilePath.exists()) {
- myFilePath.mkdir();
- }
- } catch (Exception e) {
- System.out.println("新建目录操作出错 ");
- e.printStackTrace();
- }
- }
- /**
- * 新建文件
- *
- * @param filePathAndName
- * String 文件路径及名称 如c:/fqf.txt
- * @param fileContent
- * String 文件内容
- * @return boolean
- */
- public void newFile(String filePathAndName, String fileContent) {
- try {
- String filePath = filePathAndName;
- filePath = filePath.toString();
- File myFilePath = new File(filePath);
- if (!myFilePath.exists()) {
- myFilePath.createNewFile();
- }
- FileWriter resultFile = new FileWriter(myFilePath);
- PrintWriter myFile = new PrintWriter(resultFile);
- String strContent = fileContent;
- myFile.println(strContent);
- resultFile.close();
- } catch (Exception e) {
- System.out.println("新建文件操作出错 ");
- e.printStackTrace();
- }
- }
- /**
- * 删除文件
- *
- * @param filePathAndName
- * String 文件路径及名称 如c:/fqf.txt
- * @param fileContent
- * String
- * @return boolean
- */
- public void delFile(String filePathAndName) {
- try {
- String filePath = filePathAndName;
- filePath = filePath.toString();
- java.io.File myDelFile = new java.io.File(filePath);
- myDelFile.delete();
- } catch (Exception e) {
- System.out.println("删除文件操作出错 ");
- e.printStackTrace();
- }
- }
- /**
- * 删除文件夹
- *
- * @param filePathAndName
- * String 文件夹路径及名称 如c:/fqf
- * @param fileContent
- * String
- * @return boolean
- */
- public void delFolder(String folderPath) {
- try {
- delAllFile(folderPath); // 删除完里面所有内容
- String filePath = folderPath;
- filePath = filePath.toString();
- java.io.File myFilePath = new java.io.File(filePath);
- myFilePath.delete(); // 删除空文件夹
- } catch (Exception e) {
- System.out.println("删除文件夹操作出错 ");
- e.printStackTrace();
- }
- }
- /**
- * 删除文件夹里面的所有文件
- *
- * @param path
- * String 文件夹路径 如 c:/fqf
- */
- public void delAllFile(String path) {
- File file = new File(path);
- if (!file.exists()) {
- return;
- }
- if (!file.isDirectory()) {
- return;
- }
- String[] tempList = file.list();
- File temp = null;
- for (int i = 0; i < tempList.length; i++) {
- if (path.endsWith(File.separator)) {
- temp = new File(path + tempList[i]);
- } else {
- temp = new File(path + File.separator + tempList[i]);
- }
- if (temp.isFile()) {
- temp.delete();
- }
- if (temp.isDirectory()) {
- delAllFile(path + "/ " + tempList[i]);// 先删除文件夹里面的文件
- delFolder(path + "/ " + tempList[i]);// 再删除空文件夹
- }
- }
- }
- /**
- * 复制单个文件
- *
- * @param oldPath
- * String 原文件路径 如:c:/fqf.txt
- * @param newPath
- * String 复制后路径 如:f:/fqf.txt
- * @return boolean
- */
- public void copyFile(String oldPath, String newPath) {
- try {
- int bytesum = 0;
- int byteread = 0;
- File oldfile = new File(oldPath);
- if (oldfile.exists()) { // 文件存在时
- InputStream inStream = new FileInputStream(oldPath); // 读入原文件
- FileOutputStream fs = new FileOutputStream(newPath);
- byte[] buffer = new byte[1444];
- int length;
- while ((byteread = inStream.read(buffer)) != -1) {
- bytesum += byteread; // 字节数 文件大小
- System.out.println(bytesum);
- fs.write(buffer, 0, byteread);
- }
- inStream.close();
- }
- } catch (Exception e) {
- System.out.println("复制单个文件操作出错 ");
- e.printStackTrace();
- }
- }
- /**
- * 复制整个文件夹内容
- *
- * @param oldPath
- * String 原文件路径 如:c:/fqf
- * @param newPath
- * String 复制后路径 如:f:/fqf/ff
- * @return boolean
- */
- public void copyFolder(String oldPath, String newPath) {
- try {
- (new File(newPath)).mkdirs(); // 如果文件夹不存在 则建立新文件夹
- File a = new File(oldPath);
- String[] file = a.list();
- File temp = null;
- for (int i = 0; i < file.length; i++) {
- if (oldPath.endsWith(File.separator)) {
- temp = new File(oldPath + file[i]);
- } else {
- temp = new File(oldPath + File.separator + file[i]);
- }
- if (temp.isFile()) {
- FileInputStream input = new FileInputStream(temp);
- FileOutputStream output = new FileOutputStream(newPath
- + "/ " + (temp.getName()).toString());
- byte[] b = new byte[1024 * 5];
- int len;
- while ((len = input.read(b)) != -1) {
- output.write(b, 0, len);
- }
- output.flush();
- output.close();
- input.close();
- }
- if (temp.isDirectory()) {// 如果是子文件夹
- copyFolder(oldPath + "/ " + file[i], newPath + "/ "
- + file[i]);
- }
- }
- } catch (Exception e) {
- System.out.println("复制整个文件夹内容操作出错 ");
- e.printStackTrace();
- }
- }
- /**
- * 移动文件到指定目录
- *
- * @param oldPath
- * String 如:c:/fqf.txt
- * @param newPath
- * String 如:d:/fqf.txt
- */
- public void moveFile(String oldPath, String newPath) {
- copyFile(oldPath, newPath);
- delFile(oldPath);
- }
- /**
- * 移动文件到指定目录
- *
- * @param oldPath
- * String 如:c:/fqf.txt
- * @param newPath
- * String 如:d:/fqf.txt
- */
- public void moveFolder(String oldPath, String newPath) {
- copyFolder(oldPath, newPath);
- delFolder(oldPath);
- }
- }
发表评论
-
JVM内存管理及性能调优(内存溢出、内存泄漏)
2015-09-02 07:14 701JAVA内存管理(内存溢出、内存泄漏)相关参考: JA ... -
JAVA可变参数对重载的影响
2014-01-27 15:28 941package com.lwf.test; publi ... -
有关String类创建几个对象的问题
2013-07-09 23:18 1342试题一: String s = new String(& ... -
JDK1.5下实现JDK1.6的Arrays.copyOfRange() 方法
2012-08-29 10:59 1770public static void test(){ i ... -
JAVA四舍五入的处理
2012-02-11 10:47 1025如下,保留两个小数位 double f = 3 ... -
Comparator实现排序
2011-11-16 01:23 1245转自:Comparator实现排序 在java.util包 ... -
JAVA定时器使用
2011-08-19 11:05 785http://hualong.iteye.com/blog/5 ... -
JDK5.0 Annotation学习笔记
2011-07-26 22:48 757http://linliangyi2007.iteye.com ... -
JAVA CP命令
2010-12-31 11:51 10307java -cp .;c:\dir1\lib.jar Test ... -
JDK1.5的新特性及应用
2010-07-13 12:49 1018以下两文: http://heaven-arch.iteye ... -
JAVA面试题150例
2010-05-19 11:44 2065一、Java基础方面 1、作用域public,priva ... -
《thinking in java》第四章:初始化与清理三
2010-05-19 00:21 790http://quicker.iteye.com/blog/5 ... -
JAVA编程思想第四版完整下载地址
2010-05-18 18:35 1270http://hi.baidu.com/yang1101190 ... -
JAVA多线程学习一
2010-04-13 17:21 937http://renyangok.iteye.com/blog ... -
JAVA常用误区整理
2008-01-09 13:12 9161、 float f=1.3;是不对的,编译时会出错,java ... -
try与finally块中return的问题
2008-12-05 14:37 1255针对以下情况进行测试: 情况1:try{} catch( ... -
简单克隆与深度克隆的思考
2008-12-19 16:44 1043白话简单克隆和深度克隆一文 http://blog.csd ... -
一道面试题引发的思考之:类的初始化
2008-12-29 16:23 723本人曾写过JAVA基础方面的blog,也是针对类的初始化的, ... -
JAVA基础学习篇----对象串行化及Transient关键字的使用
2009-01-08 18:07 0http://blog.csdn.net/scruffybea ... -
!JAVA学习提高之---- JAVA日期格式化及相关操作
2009-01-13 17:02 803http://blog.csdn.net/gubaohua/a ...
相关推荐
### 知识点详解 #### 一、二级目录结构及其...通过以上分析可以看出,本实习通过模拟实现采用了二级目录结构的磁盘文件系统中的文件操作,不仅加深了对文件系统原理的理解,还锻炼了数据结构设计和算法实现的能力。
模拟实现采用二级目录结构的磁盘文件系统中的文件操作。 文件系统是操作系统中管理和存取信息的机构,它具有“按名存取”的功能,不仅方便用户,而且能提高系统效率且安全可靠。 在用户程序中可使用文件系统提供的...
CANoe/CAPL 文件操作脚本是用于自动化处理CANoe环境中的配置、数据记录和分析的编程工具。CANoe是一款广泛应用于汽车电子系统的诊断、测试和测量的软件,而CAPL(CANoe Application Programming Language)是CANoe内...
收集了21个文件操作VC 源码实例,基础级别的VC 文件操作实例,获得INI文件指定段的全部键名和键值、文件对话框、临时文件创建、目录创建、获得INI文件的全部段名、查找文件、复制文件、获得或设置进程的当前目录、...
在本教程中,我们将重点讨论如何通过JNI在Android应用中进行文件操作。 首先,要使用JNI,我们需要在Java类中声明native方法。例如,我们可以声明一个名为`readFileFromNative`的方法: ```java public class ...
java文件操作类java文件操作类java文件操作类java文件操作类java文件操作类java文件操作类java文件操作类java文件操作类java文件操作类java文件操作类java文件操作类java文件操作类java文件操作类java文件操作类java...
大学本科操作系统实验 《磁盘文件操作模拟C语言》,花了两天的时间调试。
原数据存放在StreamingAsset中,首次启动复制到persistentDataPath,以后进行更新和读取都在persistentDataPath中使用File进行文件操作。需要恢复书序的时候从StreamingAsset中获取即可。
js实现的读写文件,文件放在的c:\12.txt里
JSP文件操作
C#编程 文件操作 ManageFileByType(源码)(源码)C#编程 文件操作 ManageFileByType(源码)(源码)C#编程 文件操作 ManageFileByType(源码)(源码)C#编程 文件操作 ManageFileByType(源码)(源码)C#编程 文件操作 ...
C#编程 文件操作 DeleteDirByDG(源码)(源码)C#编程 文件操作 DeleteDirByDG(源码)(源码)C#编程 文件操作 DeleteDirByDG(源码)(源码)C#编程 文件操作 DeleteDirByDG(源码)(源码)C#编程 文件操作 DeleteDirByDG(源码)...
C#编程 文件操作 OperateXML(源码)(源码)C#编程 文件操作 OperateXML(源码)(源码)C#编程 文件操作 OperateXML(源码)(源码)C#编程 文件操作 OperateXML(源码)(源码)C#编程 文件操作 OperateXML(源码)(源码)C#编程 ...
操作系统实验四的核心目标是设计和实现一个简单的...通过这样的实验,学生能够深入理解文件系统如何管理磁盘空间,跟踪文件元数据,以及如何执行基本的文件操作,这对理解和设计更复杂的操作系统有着至关重要的作用。
根据提供的信息,我们可以总结出以下关于C#文件操作的关键知识点: ### 1. 创建文件夹 在C#中,可以通过`System.IO`命名空间中的`Directory.CreateDirectory`方法来创建一个新的文件夹。 ```csharp using System....
在VC++环境中进行PDF文件操作是一项常见的任务,尤其在开发桌面应用程序时,可能需要读取、编辑或生成PDF文档。本篇文章将详细讲解如何在VC++中实现这些功能,主要涉及的技术点包括PDF文件的基本概念、PDF库的使用...
在“LabVIEW文件操作_数据存储 VI源程序”这个主题中,我们将深入探讨如何使用LabVIEW进行文件操作,特别是数据的读取与存储。 一、LabVIEW的数据存储 1. **电子表格(Excel)文件操作**:LabVIEW提供了强大的...
C# 文件操作案例分析 本文将对 C# 窗体文件操作案例进行详细分析,涵盖文件操作的基本概念、文件流操作、文本和二进制文件读写、文件属性读取等知识点。 文件操作基本概念 文件操作是计算机编程中最基本的操作之...
在Linux系统中,C语言是进行系统级编程的首选语言,尤其在文件操作方面,它提供了丰富的函数库和系统调用来处理各种文件操作任务。本教程将深入探讨如何使用C语言中的结构体来管理和操作文件。 首先,让我们理解...
通过对具体的文件存储空间的管理、文件的物理结构、目录结构和文件操作的实现,加深对文件系统内部功能和实现过程的理解。 要求: 1.在内存中开辟一个虚拟磁盘空间作为文件存储器,在其上实现一个简单的单用户文件...