代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
Java
】
文件读写操作工具类
作者:
Gooogle
/ 发布于
2012/3/6
/
845
<div>package util;</div> <div></div> import java.io.BufferedReader;</div> import java.io.File;</div> import java.io.FileInputStream;</div> import java.io.FileReader;</div> import java.io.FileWriter;</div> import java.io.IOException;</div> import java.io.InputStream;</div> import java.io.InputStreamReader;</div> import java.io.RandomAccessFile;</div> import java.io.Reader;</div> <div></div> <div>/**</div> <div>*</div> <div>* @类名: FileUtil</div> <div>* @作用: TODO</div> <div>* @日期: 2012-3-1 下午04:58:31</div> <div>*/</div> <div></div> <div>public class FileUtil {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>/**</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> * 以字节为单位读取文件,常用于读二进制文件,如图片、声音、影像等文件。</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> * @param fileName 文件的名</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> */</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>public static void readFileByBytes(String fileName) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>File file = new File(fileName);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>InputStream in = null;</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>try {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>System.out.println("以字节为单位读取文件内容,一次读一个字节:");</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// 一次读一个字节</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>in = new FileInputStream(file);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>int tempbyte;</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>while ((tempbyte = in.read()) != -1) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>System.out.write(tempbyte);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div><span class="Apple-tab-span" style="white-space:pre"> </span>in.close();</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} catch (IOException e) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>e.printStackTrace();</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>return;</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div><span class="Apple-tab-span" style="white-space:pre"> </span>try {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>System.out.println("以字节为单位读取文件内容,一次读多个字节:");</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// 一次读多个字节</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>byte[] tempbytes = new byte[100];</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>int byteread = 0;</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>in = new FileInputStream(fileName);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>FileUtil.showAvailableBytes(in);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// 读入多个字节到字节数组中,byteread为一次读入的字节数</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>while ((byteread = in.read(tempbytes)) != -1) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>System.out.write(tempbytes, 0, byteread);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div><span class="Apple-tab-span" style="white-space:pre"> </span>} catch (Exception e1) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>e1.printStackTrace();</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} finally {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>if (in != null) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>try {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>in.close();</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} catch (IOException e1) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div></div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>/**</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> * 以字符为单位读取文件,常用于读文本,数字等类型的文件</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> *</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> * @param fileName</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> * 文件名</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> */</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>public static void readFileByChars(String fileName) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>File file = new File(fileName);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>Reader reader = null;</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>try {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>System.out.println("以字符为单位读取文件内容,一次读一个字节:");</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// 一次读一个字符</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>reader = new InputStreamReader(new FileInputStream(file));</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>int tempchar;</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>while ((tempchar = reader.read()) != -1) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// 对于windows下,rn这两个字符在一起时,表示一个换行。</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// 但如果这两个字符分开显示时,会换两次行。</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// 因此,屏蔽掉r,或者屏蔽n。否则,将会多出很多空行。</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>if (((char) tempchar) != 'r') {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>System.out.print((char) tempchar);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div><span class="Apple-tab-span" style="white-space:pre"> </span>reader.close();</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} catch (Exception e) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>e.printStackTrace();</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div><span class="Apple-tab-span" style="white-space:pre"> </span>try {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>System.out.println("以字符为单位读取文件内容,一次读多个字节:");</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// 一次读多个字符</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>char[] tempchars = new char[30];</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>int charread = 0;</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>reader = new InputStreamReader(new FileInputStream(fileName));</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// 读入多个字符到字符数组中,charread为一次读取字符数</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>while ((charread = reader.read(tempchars)) != -1) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// 同样屏蔽掉r不显示</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>if ((charread == tempchars.length)</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>&& (tempchars[tempchars.length - 1] != 'r')) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>System.out.print(tempchars);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} else {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>for (int i = 0; i < charread; i++) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>if (tempchars[i] == 'r') {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>continue;</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} else {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>System.out.print(tempchars[i]);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div><span class="Apple-tab-span" style="white-space:pre"> </span>} catch (Exception e1) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>e1.printStackTrace();</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} finally {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>if (reader != null) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>try {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>reader.close();</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} catch (IOException e1) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div></div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>/**</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> * 以行为单位读取文件,常用于读面向行的格式化文件</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> *</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> * @param fileName</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> * 文件名</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> */</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>public static void readFileByLines(String fileName) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>File file = new File(fileName);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>BufferedReader reader = null;</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>try {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>System.out.println("以行为单位读取文件内容,一次读一整行:");</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>reader = new BufferedReader(new FileReader(file));</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>String tempString = null;</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>int line = 1;</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// 一次读入一行,直到读入null为文件结束</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>while ((tempString = reader.readLine()) != null) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// 显示行号</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>System.out.println("line " + line + ": " + tempString);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>line++;</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div><span class="Apple-tab-span" style="white-space:pre"> </span>reader.close();</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} catch (IOException e) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>e.printStackTrace();</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} finally {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>if (reader != null) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>try {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>reader.close();</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} catch (IOException e1) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div></div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>/**</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> * 随机读取文件内容</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> *</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> * @param fileName</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> * 文件名</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> */</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>public static void readFileByRandomAccess(String fileName) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>RandomAccessFile randomFile = null;</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>try {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>System.out.println("随机读取一段文件内容:");</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// 打开一个随机访问文件流,按只读方式</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>randomFile = new RandomAccessFile(fileName, "r");</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// 文件长度,字节数</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>long fileLength = randomFile.length();</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// 读文件的起始位置</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>int beginIndex = (fileLength > 4) ? 4 : 0;</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// 将读文件的开始位置移到beginIndex位置。</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>randomFile.seek(beginIndex);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>byte[] bytes = new byte[10];</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>int byteread = 0;</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// 一次读10个字节,如果文件内容不足10个字节,则读剩下的字节。</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// 将一次读取的字节数赋给byteread</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>while ((byteread = randomFile.read(bytes)) != -1) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>System.out.write(bytes, 0, byteread);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div><span class="Apple-tab-span" style="white-space:pre"> </span>} catch (IOException e) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>e.printStackTrace();</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} finally {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>if (randomFile != null) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>try {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>randomFile.close();</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} catch (IOException e1) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div></div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>/**</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> * 显示输入流中还剩的字节数</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> *</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> * @param in</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> */</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>private static void showAvailableBytes(InputStream in) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>try {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>System.out.println("当前字节输入流中的字节数为:" + in.available());</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} catch (IOException e) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>e.printStackTrace();</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div></div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>public static void main(String[] args) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>String fileName = "C:/temp/newTemp.txt";</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// ReadFromFile.readFileByBytes(fileName);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// /ReadFromFile.readFileByChars(fileName);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// ReadFromFile.readFileByLines(fileName);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// ReadFromFile.readFileByRandomAccess(fileName);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div></div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>/**</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> * A方法追加文件:使用RandomAccessFile</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> *</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> * @param fileName</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> * 文件名</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> * @param content</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> * 追加的内容</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> */</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>public static void appendMethodA(String fileName, String content) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>try {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// 打开一个随机访问文件流,按读写方式</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>RandomAccessFile randomFile = new RandomAccessFile(fileName, "rw");</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// 文件长度,字节数</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>long fileLength = randomFile.length();</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// 将写文件指针移到文件尾。</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>randomFile.seek(fileLength);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>randomFile.writeBytes(content);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>randomFile.close();</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} catch (IOException e) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>e.printStackTrace();</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div></div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>/**</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> * B方法追加文件:使用FileWriter</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> *</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> * @param fileName</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> * @param content</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span> */</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>public static void appendMethodB(String fileName, String content) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>try {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// 打开一个写文件器,构造函数中的第二个参数true表示以追加形式写文件</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>FileWriter writer = new FileWriter(fileName, true);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>writer.write(content);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>writer.close();</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} catch (IOException e) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>e.printStackTrace();</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div></div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>public static void main1(String[] args) {</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>String fileName = "C:/temp/newTemp.txt";</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>String content = "new append!";</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// 按方法A追加文件</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// AppendToFile.appendMethodA(fileName, content);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// AppendToFile.appendMethodA(fileName, "append end. n");</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// 显示文件内容</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// ReadFromFile.readFileByLines(fileName);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// 按方法B追加文件</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// AppendToFile.appendMethodB(fileName, content);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// AppendToFile.appendMethodB(fileName, "append end. n");</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// 显示文件内容</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>// ReadFromFile.readFileByLines(fileName);</div> <div><span class="Apple-tab-span" style="white-space:pre"> </span>} <div>} <div></div>
试试其它关键字
读写操作工具
同语言下
.
List 切割成几份 工具类
.
一行一行读取txt的内容
.
Java PDF转换成图片并输出给前台展示
.
java 多线程框架
.
double类型如果小数点后为零则显示整数否则保留两位小
.
将图片转换为Base64字符串公共类抽取
.
sqlParser 处理SQL(增删改查) 替换schema 用于多租户
.
JAVA 月份中的第几周处理 1-7属于第一周 依次类推 29-
.
java计算两个经纬度之间的距离
.
输入时间参数计算年龄
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
Gooogle
贡献的其它代码
(
3
)
.
将人民币数字转换成大写形式
.
二叉树递归,非递归遍历
.
文件读写操作工具类
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3