java将一个对象写入文件
Java object can write into a file for future access, this is called serialization. In order to do this, you have to implement the Serializableinterfac[......] Read more
View ArticleJava检查一个文件是否存在
Java检查一个文件是否存在,使用 File.exists(). import java.io.*; public class FileChecker { public static void main(String args[]) { File f =[......] Read more
View Articlejava获取可以磁盘空间大小
In Java old days, it lacks of method to determine the free disk space on a partition. But this is changed since JDK 1.6 released, a few new methods –[......] Read more
View ArticleJava向文件中写入UTF-8编码的数据
本例使用java将 UTF-8 encoded data 写入文件 “c:\\temp\\test.txt” P.S Symbol “??” is some “UTF-8″ data in Chinese and Japanese import java.io.BufferedW[......] Read more
View Article压缩序列化的对象到文件
本例介绍,压缩序列化的对象到文件,以减小文件大小。 思路很简单,即使用 “GZIPOutputStream”进行数据压缩. FileOutputStream fos = new FileOutputStream("c:\\address.gz"); GZIPOutputStream[......] Read more
View Article怎样解压缩gzip文件
本文介绍怎样解压缩gzip文件 Gzip example 本例解压缩文件 “/home/mkyong/file1.gz” back to “/home/mkyong/file1.txt“. import java.io.FileInputStream; import java.i[......] Read more
View Articlejava检查隐藏文件
通过 java.io.File isHidden() 检查一个文件是否隐藏。 import java.io.File; import java.io.IOException; public class FileHidden { public static voi[......] Read more
View Articlejava怎样删除目录
java中可以使用 File.delete() 删除目录, 但是被删除的目录必须是空的才可以。 很多时候,我们需要递归删除一个目录( recursive delete in a directory), 这意味着该目录的所有子目录和该目录下的文件都需要被删除。下面是一个例子: Director[......] Read more
View ArticleJava将InputStream 转为String
Java中可以使用 BufferedReader + InputStreamReader将InputStream 转为String InputStreamToStringExample.java import java.io.BufferedReader; import java[......] Read more
View ArticleJava得到一个文件的行数
The LineNumberReader class is a useful class to handle the lines of a file, you can loop the LineNumberReader.readLine() method and accumulate it as t[......] Read more
View Article
More Pages to Explore .....