文件辅助类封装

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace Manjinba.Communication.Common.Utils
{
/// <summary>
/// 文件辅助类
/// </summary>
public class FileHelper
{
#region 检测指定目录是否存在
/// <summary>
/// 检测指定目录是否存在
/// </summary>
/// <param name="directoryPath">目录的绝对路径</param>
public static bool IsExistDirectory(string directoryPath)
{
return Directory.Exists(directoryPath);
}
#endregion

#region 检测指定文件是否存在
/// <summary>
/// 检测指定文件是否存在,如果存在则返回true。
/// </summary>
/// <param name="filePath">文件的绝对路径</param>
public static bool IsExistFile(string filePath)
{
return File.Exists(filePath);
}
#endregion

#region 检测指定目录是否为空
/// <summary>
/// 检测指定目录是否为空
/// </summary>
/// <param name="directoryPath">指定目录的绝对路径</param>
public static bool IsEmptyDirectory(string directoryPath)
{
try
{
//判断是否存在文件
string[] fileNames = GetFileNames(directoryPath);
if (fileNames.Length > 0)
{
return false;
}

//判断是否存在文件夹
string[] directoryNames = GetDirectories(directoryPath);
return directoryNames.Length <= 0;
}
catch
{
return false;
}
}
#endregion

#region 检测指定目录中是否存在指定的文件
/// <summary>
/// 检测指定目录中是否存在指定的文件,若要搜索子目录请使用重载方法.
/// </summary>
/// <param name="directoryPath">指定目录的绝对路径</param>
/// <param name="searchPattern">模式字符串,"*"代表0或N个字符,"?"代表1个字符。
/// 范例:"Log*.xml"表示搜索所有以Log开头的Xml文件。</param>
public static bool Contains(string directoryPath, string searchPattern)
{
try
{
//获取指定的文件列表
string[] fileNames = GetFileNames(directoryPath, searchPattern, false);

//判断指定文件是否存在
return fileNames.Length != 0;
}
catch
{
return false;
}
}

/// <summary>
/// 检测指定目录中是否存在指定的文件
/// </summary>
/// <param name="directoryPath">指定目录的绝对路径</param>
/// <param name="searchPattern">模式字符串,"*"代表0或N个字符,"?"代表1个字符。
/// 范例:"Log*.xml"表示搜索所有以Log开头的Xml文件。</param>
/// <param name="isSearchChild">是否搜索子目录</param>
public static bool Contains(string directoryPath, string searchPattern, bool isSearchChild)
{
try
{
//获取指定的文件列表
string[] fileNames = GetFileNames(directoryPath, searchPattern, true);

//判断指定文件是否存在
return fileNames.Length != 0;
}
catch
{
return false;
}
}
#endregion

#region 创建一个目录
/// <summary>
/// 创建一个目录
/// </summary>
/// <param name="directoryPath">目录的绝对路径</param>
public static void CreateDirectory(string directoryPath)
{
//如果目录不存在则创建该目录
if (!IsExistDirectory(directoryPath))
{
Directory.CreateDirectory(directoryPath);
}
}
#endregion

#region 创建一个文件
/// <summary>
/// 创建一个文件。
/// </summary>
/// <param name="filePath">文件的绝对路径</param>
public static bool CreateFile(string filePath)
{
try
{
//如果文件不存在则创建该文件
if (!IsExistFile(filePath))
{
//创建一个FileInfo对象
FileInfo file = new FileInfo(filePath);
//创建文件
FileStream fs = file.Create();
//关闭文件流
fs.Close();
}
}
catch
{
return false;
}

return true;
}

/// <summary>
/// 创建一个文件,并将字节流写入文件。
/// </summary>
/// <param name="filePath">文件的绝对路径</param>
/// <param name="buffer">二进制流数据</param>
public static bool CreateFile(string filePath, byte[] buffer)
{
try
{
//如果文件不存在则创建该文件
if (!IsExistFile(filePath))
{
//创建一个FileInfo对象
FileInfo file = new FileInfo(filePath);

//创建文件
FileStream fs = file.Create();

//写入二进制流
fs.Write(buffer, 0, buffer.Length);

//关闭文件流
fs.Close();
}
}
catch
{
return false;
}
return true;
}
#endregion

#region 获取文件流
/// <summary>
/// 获取文件留
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
public static Stream GetFileStream(string filePath)
{
//循环读取大文本文件
FileStream fs;
//用FileStream文件流打开文件
try
{
fs = new FileStream(@filePath, FileMode.Open);
}
catch (Exception)
{
throw;
}
var outputStream = new MemoryStream();
//还没有读取的文件内容长度
long leftLength = fs.Length;
//创建接收文件内容的字节数组
byte[] buffer = new byte[2048];
//每次读取的最大字节数
int maxLength = buffer.Length;
//每次实际返回的字节数长度
int num = 0;
//文件开始读取的位置
int fileStart = 0;
while (leftLength > 0)
{
//设置文件流的读取位置
fs.Position = fileStart;
if (leftLength < maxLength)
{
num = fs.Read(buffer, 0, Convert.ToInt32(leftLength));
outputStream.Write(buffer, 0, Convert.ToInt32(leftLength));
}
else
{
num = fs.Read(buffer, 0, maxLength);
outputStream.Write(buffer, 0, maxLength);
}
if (num == 0)
{
break;
}
fileStart += num;
leftLength -= num;
}
fs.Close();
return outputStream;
}
#endregion

#region 获取文本文件的行数
/// <summary>
/// 获取文本文件的行数
/// </summary>
/// <param name="filePath">文件的绝对路径</param>
public static int GetLineCount(string filePath)
{
//将文本文件的各行读到一个字符串数组中
string[] rows = File.ReadAllLines(filePath);

//返回行数
return rows.Length;
}
#endregion

#region 获取一个文件的长度
/// <summary>
/// 获取一个文件的长度,单位为Byte
/// </summary>
/// <param name="filePath">文件的绝对路径</param>
public static int GetFileSize(string filePath)
{
//创建一个文件对象
FileInfo fi = new FileInfo(filePath);

//获取文件的大小
return (int)fi.Length;
}

/// <summary>
/// 获取一个文件的长度,单位为KB
/// </summary>
/// <param name="filePath">文件的路径</param>
public static double GetFileSizeByKB(string filePath)
{
//创建一个文件对象
FileInfo fi = new FileInfo(filePath);
long size = fi.Length / 1024;
//获取文件的大小
return double.Parse(size.ToString());
}

/// <summary>
/// 获取一个文件的长度,单位为MB
/// </summary>
/// <param name="filePath">文件的路径</param>
public static double GetFileSizeByMB(string filePath)
{
//创建一个文件对象
FileInfo fi = new FileInfo(filePath);
long size = fi.Length / 1024 / 1024;
//获取文件的大小
return double.Parse(size.ToString());
}
#endregion

#region 获取指定目录中的文件列表
/// <summary>
/// 获取指定目录中所有文件列表
/// </summary>
/// <param name="directoryPath">指定目录的绝对路径</param>
public static string[] GetFileNames(string directoryPath)
{
//如果目录不存在,则抛出异常
if (!IsExistDirectory(directoryPath))
{
throw new FileNotFoundException();
}

//获取文件列表
return Directory.GetFiles(directoryPath);
}

/// <summary>
/// 获取指定目录及子目录中所有文件列表
/// </summary>
/// <param name="directoryPath">指定目录的绝对路径</param>
/// <param name="searchPattern">模式字符串,"*"代表0或N个字符,"?"代表1个字符。
/// 范例:"Log*.xml"表示搜索所有以Log开头的Xml文件。</param>
/// <param name="isSearchChild">是否搜索子目录</param>
public static string[] GetFileNames(string directoryPath, string searchPattern, bool isSearchChild)
{
//如果目录不存在,则抛出异常
if (!IsExistDirectory(directoryPath))
{
throw new FileNotFoundException();
}

try
{
return Directory.GetFiles(directoryPath, searchPattern, isSearchChild ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
}
catch
{
return null;
}
}
#endregion

#region 获取指定目录中的子目录列表
/// <summary>
/// 获取指定目录中所有子目录列表,若要搜索嵌套的子目录列表,请使用重载方法.
/// </summary>
/// <param name="directoryPath">指定目录的绝对路径</param>
public static string[] GetDirectories(string directoryPath)
{
try
{
return Directory.GetDirectories(directoryPath);
}
catch
{
return null;
}
}

/// <summary>
/// 获取指定目录及子目录中所有子目录列表
/// </summary>
/// <param name="directoryPath">指定目录的绝对路径</param>
/// <param name="searchPattern">模式字符串,"*"代表0或N个字符,"?"代表1个字符。
/// 范例:"Log*.xml"表示搜索所有以Log开头的Xml文件。</param>
/// <param name="isSearchChild">是否搜索子目录</param>
public static string[] GetDirectories(string directoryPath, string searchPattern, bool isSearchChild)
{
try
{
return Directory.GetDirectories(directoryPath, searchPattern, isSearchChild ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
}
catch
{
throw null;
}
}
#endregion

#region 向文本文件写入内容
/// <summary>
/// 向文本文件中写入内容
/// </summary>
/// <param name="filePath">文件的绝对路径</param>
/// <param name="content">写入的内容</param>
public static void WriteText(string filePath, string content)
{
//向文件写入内容
File.WriteAllText(filePath, content);
}
#endregion

#region 向文本文件的尾部追加内容
/// <summary>
/// 向文本文件的尾部追加内容
/// </summary>
/// <param name="filePath">文件的绝对路径</param>
/// <param name="content">写入的内容</param>
public static void AppendText(string filePath, string content)
{
File.AppendAllText(filePath, content);
}
#endregion

#region 将现有文件的内容复制到新文件中
/// <summary>
/// 将源文件的内容复制到目标文件中
/// </summary>
/// <param name="sourceFilePath">源文件的绝对路径</param>
/// <param name="destFilePath">目标文件的绝对路径</param>
public static void Copy(string sourceFilePath, string destFilePath)
{
File.Copy(sourceFilePath, destFilePath, true);
}
#endregion

#region 复制整个文件夹
/// <summary>
/// 复制整个文件夹
/// </summary>
/// <param name="sourceFolderName">源文件夹目录</param>
/// <param name="destFolderName">目标文件夹目录</param>
public static void FullCopy(string sourceFolderName, string destFolderName)
{
FullCopy(sourceFolderName, destFolderName, true);
}
#endregion

#region 复制整个文件夹
/// <summary>
/// 复制整个文件夹
/// </summary>
/// <param name="sourceFolderName">源文件夹目录</param>
/// <param name="destFolderName">目标文件夹目录</param>
/// <param name="overwrite">允许覆盖文件</param>
public static void FullCopy(string sourceFolderName, string destFolderName, bool overwrite)
{
var sourceFilesPath = Directory.GetFileSystemEntries(sourceFolderName);

for (int i = 0; i < sourceFilesPath.Length; i++)
{
var sourceFilePath = sourceFilesPath[i];
var directoryName = Path.GetDirectoryName(sourceFilePath);
var forlders = directoryName.Split('\\');
var lastDirectory = forlders[forlders.Length - 1];
var dest = Path.Combine(destFolderName, lastDirectory);

if (File.Exists(sourceFilePath))
{
var sourceFileName = Path.GetFileName(sourceFilePath);
if (!Directory.Exists(dest))
{
Directory.CreateDirectory(dest);
}
File.Copy(sourceFilePath, Path.Combine(dest, sourceFileName), overwrite);
}
else
{
FullCopy(sourceFilePath, dest, overwrite);
}
}
}
#endregion

#region 将文件移动到指定目录
/// <summary>
/// 将文件移动到指定目录
/// </summary>
/// <param name="sourceFilePath">需要移动的源文件的绝对路径</param>
/// <param name="descDirectoryPath">移动到的目录的绝对路径</param>
public static void Move(string sourceFilePath, string descDirectoryPath)
{
//获取源文件的名称
string sourceFileName = GetFileName(sourceFilePath);

if (IsExistDirectory(descDirectoryPath))
{
//如果目标中存在同名文件,则删除
if (IsExistFile(descDirectoryPath + "\\" + sourceFileName))
{
DeleteFile(descDirectoryPath + "\\" + sourceFileName);
}
//将文件移动到指定目录
File.Move(sourceFilePath, descDirectoryPath + "\\" + sourceFileName);
}
}
#endregion

#region 将流读取到缓冲区中
/// <summary>
/// 将流读取到缓冲区中
/// </summary>
/// <param name="stream">原始流</param>
public static byte[] StreamToBytes(Stream stream)
{
try
{
//创建缓冲区
byte[] buffer = new byte[stream.Length];

//读取流
stream.Read(buffer, 0, int.Parse(stream.Length.ToString()));

//返回流
return buffer;
}
catch
{
return null;
}
finally
{
//关闭流
stream.Close();
}
}
#endregion

#region 将文件读取到缓冲区中
/// <summary>
/// 将文件读取到缓冲区中
/// </summary>
/// <param name="filePath">文件的绝对路径</param>
public static byte[] FileToBytes(string filePath)
{
//获取文件的大小
int fileSize = GetFileSize(filePath);

//创建一个临时缓冲区
byte[] buffer = new byte[fileSize];

//创建一个文件流
FileInfo fi = new FileInfo(filePath);
FileStream fs = fi.Open(FileMode.Open);

try
{
//将文件流读入缓冲区
fs.Read(buffer, 0, fileSize);

return buffer;
}
catch
{
return null;
}
finally
{
//关闭文件流
fs.Close();
}
}
#endregion

#region 将文件读取到字符串中
/// <summary>
/// 将文件读取到字符串中
/// </summary>
/// <param name="filePath">文件的绝对路径</param>
public static string FileToString(string filePath)
{
return FileToString(filePath, Encoding.Default);
}
/// <summary>
/// 将文件读取到字符串中
/// </summary>
/// <param name="filePath">文件的绝对路径</param>
/// <param name="encoding">字符编码</param>
public static string FileToString(string filePath, Encoding encoding)
{
//创建流读取器
StreamReader reader = new StreamReader(filePath, encoding);
try
{
//读取流
return reader.ReadToEnd();
}
catch
{
return string.Empty;
}
finally
{
//关闭流读取器
reader.Close();
}
}
#endregion

#region 从文件的绝对路径中获取文件名( 包含扩展名 )
/// <summary>
/// 从文件的绝对路径中获取文件名( 包含扩展名 )
/// </summary>
/// <param name="filePath">文件的绝对路径</param>
public static string GetFileName(string filePath)
{
//获取文件的名称
FileInfo fi = new FileInfo(filePath);
return fi.Name;
}
#endregion

#region 从文件的绝对路径中获取文件名( 不包含扩展名 )
/// <summary>
/// 从文件的绝对路径中获取文件名( 不包含扩展名 )
/// </summary>
/// <param name="filePath">文件的绝对路径</param>
public static string GetFileNameNoExtension(string filePath)
{
//获取文件的名称
FileInfo fi = new FileInfo(filePath);
return fi.Name.Split('.')[0];
}
#endregion

#region 从文件的绝对路径中获取扩展名
/// <summary>
/// 从文件的绝对路径中获取扩展名
/// </summary>
/// <param name="filePath">文件的绝对路径</param>
public static string GetExtension(string filePath)
{
//获取文件的名称
FileInfo fi = new FileInfo(filePath);
return fi.Extension;
}
#endregion

#region 清空指定目录
/// <summary>
/// 清空指定目录下所有文件及子目录,但该目录依然保存.
/// </summary>
/// <param name="directoryPath">指定目录的绝对路径</param>
public static void ClearDirectory(string directoryPath)
{
if (IsExistDirectory(directoryPath))
{
//删除目录中所有的文件
string[] fileNames = GetFileNames(directoryPath);
foreach (string t in fileNames)
{
DeleteFile(t);
}

//删除目录中所有的子目录
string[] directoryNames = GetDirectories(directoryPath);
foreach (string t in directoryNames)
{
DeleteDirectory(t);
}
}
}
#endregion

#region 清空文件内容
/// <summary>
/// 清空文件内容
/// </summary>
/// <param name="filePath">文件的绝对路径</param>
public static void ClearFile(string filePath)
{
//删除文件
File.Delete(filePath);

//重新创建该文件
CreateFile(filePath);
}
#endregion

#region 删除指定文件
/// <summary>
/// 删除指定文件
/// </summary>
/// <param name="filePath">文件的绝对路径</param>
public static void DeleteFile(string filePath)
{
if (IsExistFile(filePath))
{
File.Delete(filePath);
}
}
#endregion

#region 删除指定目录
/// <summary>
/// 删除指定目录及其所有子目录
/// </summary>
/// <param name="directoryPath">指定目录的绝对路径</param>
public static void DeleteDirectory(string directoryPath)
{
if (IsExistDirectory(directoryPath))
{
Directory.Delete(directoryPath, true);
}
}
#endregion


}
}

转载于:https://www.cnblogs.com/Nine4Cool/p/10540641.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/463152.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

你知道吗…我不知道…你知道吗

很多你自以为知道却不知道的东西&#xff0c;你知道吗…我不知道…你知道吗…… 1.拉斯维加斯的赌场都没有钟。 2.麦当劳40%的利润来自Happy Meals的销售。 3.1996版的韦伯斯特词典有315处拼写错误。 4.每天平均有12个新生儿被交给错误的父母。 5.巧克力对于狗来说是致命的&…

c# 读取记事本txt文档到DataTable中

有时候我们仅仅需要用到简单的几个数据,没有必要在数据库中建立单独的表去存储这些数据然后去连接数据库等等。 例如&#xff1a;我们的程序中只需要给几个人定时发送邮件&#xff0c;而这几个人的邮件地址则可以放到txt文档中,然后读取出来即可。 从txt读取出来的数据&#xf…

通读教材第二问

我在教材第14章看到这样一段话&#xff1a;在专业时间模型中&#xff0c;一个Scrum团队负责开发项目的Product Backlog&#xff0c;同时还负责专门的时间来处理现有产品或者服务出现的问题。 请问&#xff1a;在团队项目开发中&#xff0c;专业时间模型是什么&#xff1f; 在查…

智能指针对比

智能指针对比&#xff1a; (1)、boost::shared_ptr<T> -- 基于引用计数器refcount(原子的) <1>、构造函数中refcount1&#xff0c;析构函数中refcount-1&#xff0c;当refcount的值减到为0时&#xff0c;该对象就会被销毁。 <2>、解决循环引用的问题&#x…

魔兽争霸3地图(WarIII Maps):梦若流星

魔兽争霸3地图&#xff08;WarIII Maps&#xff09;&#xff1a;梦若流星梦若流星游戏类型&#xff1a;RPG通关时间&#xff1a;30分钟流星蝴蝶剑后传&#xff0c;即使孟星魂想独善其身&#xff0c;也未必就能如愿………………为了更好的体验游戏&#xff0c;请在在“选项—声音…

Sql Server 关于整表插入另一个表部分列的语法以及select 语句直接插入临时表的语法 (转帖)...

语法是这样的 :1、说明&#xff1a;复制表(只复制结构,源表名&#xff1a;a 新表名&#xff1a;b) (Access可用) 法一&#xff1a;select * into b from a where 1 <>1 法二&#xff1a;select top 0 * into b from a 2、说明&#xff1a;拷贝表(拷贝数据,源表名&#xf…

在.Net中,如何创建一个后台执行的进程?

在.Net中&#xff0c;创建一个进程十分容易。但是如果你想创建一个没有窗口的后台进程&#xff0c;你需要对ProcessStartInfo进行一些特殊的设置&#xff1a; var process new Process() { StartInfo new ProcessStartInfo("executable file name", "argument…

WorldWind Java 版学习:1、启动过程

一、JOGL使用介绍 使用 JOGL&#xff0c;需要构造GLCapabilities、GLCanvas 和 GLEventListener 的对象&#xff0c;其中 GLCapabilities 对象用于构造 GLCanvas 对象&#xff0c;将 GLCanvas 添加到相应的 Container 中用于窗口显示&#xff0c;实现 GLEventListener 中的init…

Redis pub/sub机制在实际运用场景的理解(转载)

Redis 的pub/sub机制与23种设计模式中的观察者设计模式极为类似。但Redis对于这个机制的实现更为轻便和简结&#xff0c;没有观察者模式的那么复杂的逻辑考虑而仅仅需要通过两个Redis客户端配置channel即可实现&#xff0c;因此它也仅仅做了消息的"发布"和"订阅…

第三周学习进度总结

本周学习进度&#xff1a; 第三周3月11日至3月17日每天平均写代码时间30分钟代码量630行左右所发博客数6篇本周学到的知识点对HTMLcss的常用知识点有了大概的了解&#xff0c;对java的文件操作更加熟练了下周的计划熟练掌握本周学到的知识点&#xff0c;简单了解安卓手机端开发…

flash特效原理:图片滑动放大效果(2)

flash特效原理&#xff1a;图片滑动放大效果(1) http://blog.csdn.net/hero82748274/archive/2009/10/22/4715312.aspx 最近看了一些关于动态注册点更加的办法&#xff0c;顺手牵羊把他下载了&#xff0c;感觉挺好用。再把一个倒影类给下载了&#xff0c;结合上次一个做法&…

Windows Phone 7实现图片数据绑定

Windows Phone 7实现图片数据绑定 首先我们使用ListBox来显示多张图片&#xff0c;然后在建立一个单独的页面来显示单独的一张图片。 1.我们建立一个Picture.xaml的页面&#xff0c;并使用ListBox控件来显示多张图片的信息。&#xff0c;示例代码如下&#xff1a; <Grid x:N…

类前置声明的使用

今天在写代码时&#xff0c;遇到了是否需要加头文件的问题&#xff0c;看到这个博客之后收益匪浅&#xff0c;因此转载该篇文章。 转载&#xff1a;https://www.jianshu.com/p/9768175387b6 首先我们看这样一个示例程序: 以上代码中,类CY中有个CX类型的数据成员,我们需要在CY…

dom nodeName nodeType nodeValue

1&#xff0c;nodeName属性 &#xff1a; 节点的名字。如果节点是元素节点&#xff0c;那么返回这个元素的名字。此时&#xff0c;相当于tagName属性。比如<p>aaaa</p> : 则返回 p 如果是属性节点&#xff0c;nodeName将返回这个属性的名字。如果是文本节点&…

谈谈CLOSE_WAIT

TCP 有很多连接状态&#xff0c;每一个都够聊十块钱儿的&#xff0c;比如我们以前讨论过 TIME_WAIT 和 FIN_WAIT1&#xff0c;最近时不时听人提起 CLOSE_WAIT&#xff0c;感觉有必要梳理一下。 所谓 CLOSE_WAIT&#xff0c;借用某位大牛的话来说应该倒过来叫做 WAIT_CLOSE&…

Windows Phone 7 自适应键盘输入

在移动设备上由于空间比较小&#xff0c;例如手机的屏幕&#xff0c;所以显示完整的输入键盘不行或者不美观。因此程序需要处理键盘的呈现&#xff0c;比如一个Textbox控件&#xff0c;我们只想输入数字&#xff0c;那么如果不处理还会显示字母的输入界面&#xff0c;这样即占用…

201673020127 词频统计软件项目报告

需求分析 从给定文本中得出单词频数的统计数据。 功能设计 首要功能是统计指定文本中的词频&#xff0c;保证其健壮性。在此基础上还需实现显示对指定单词的统计结果&#xff0c;显示指定数目高频单词的统计结果以及将统计结果输出至结果文件等功能。 设计实现 主程序使用无限循…

如何把Access转成SQL Server的方法介绍

1、打开“控制面板”下“管理工具”中的“数据库源”。 2、按“添加”添加一个新的数据源&#xff0c;在选择栏里选“Driver do microsoft Access (*.mdb)”&#xff0c;完成后将出现一个框&#xff0c;在“数据库源”里面输入你想写的名称&#xff0c;我取名叫“ABC”&#xf…

c/c++ 前置声明 -- typedef问题

前几天写过前置声明的问题&#xff0c;不过今天写代码时又遇到了同样的问题&#xff0c;不过是一个typedef出来的问题。 前置声明的好处很多, 比如能避免头文件互相包含的冲突, 比如有时我们在一个头文件中只需要另一个头文件的某个类型定义, 只需要对它做一下前置声明即可, 因…

.读取excel表格(JAVA)

读取excel表格&#xff08;JAVA&#xff09;偶尔写个小程序&#xff0c;让办公更简单一些。在这里使用到JXL(Java Excel API)用来动态读写Excel文件。JXL的主页是&#xff1a;http://www.andykhan.com/jexcelapi/&#xff0c;可以在这里下载到它的最新的版本。将包下载下来后将…