java io教程
Java provides several classes in java.io
package to work with text, stream data, and file system. I have provided several examples on Java Files and Java IO recently. This post is an index of all Java IO articles.
Java在java.io
包中提供了几个类来处理文本,流数据和文件系统。 我最近提供了一些有关Java文件和Java IO的示例。 这篇文章是所有Java IO文章的索引。
Java IO (Java IO)
- How to Create New File in Java
In this post, you will learn how to create a new file in java program and use of “file.separator” system property to make our program platform independent.
如何用Java创建新文件在本文中,您将学习如何在Java程序中创建一个新文件,以及如何使用“ file.separator ”系统属性来使我们的程序平台独立。
- How to delete a File in Java
This post explains how to delete a file or empty directory in java, notice that delete doesn’t throw any exception even if directory is not empty and not deleted.
如何用Java删除文件这篇文章解释了如何在Java中删除文件或空目录,请注意,即使目录不为空且未删除,删除也不会引发任何异常。
- Java File separator, separatorChar, pathSeparator, pathSeparatorChar Explained with Example
Learn about the four separator static variables of File class.
Java文件分隔符,separatorChar,pathSeparator,pathSeparatorChar用示例解释了解File类的四个分隔符静态变量。
- How to delete non empty directory in Java
A recursive program to delete non-empty directories in java.
如何在Java中删除非空目录删除Java中非空目录的递归程序。
- Rename file or Move file in Java
Learn how easily you can rename a file or move it into other directory in java.
用Java重命名文件或移动文件了解如何轻松地重命名文件或将其移动到Java中的其他目录。
- File Size in Java
Learn how to get the file size in java program.
Java中的文件大小了解如何在Java程序中获取文件大小。
- Get File Extension in Java
Java File doesn’t have any method to get file extension, a utility program showing how to get file extension in java.
获取Java文件扩展名Java File没有任何方法来获取文件扩展名,这是一个实用程序,显示了如何在Java中获取文件扩展名。
- Check File Exists in Java
Learn how to check if file exists or not in java.
检查Java中文件是否存在了解如何在Java中检查文件是否存在。
- How to check if File is Directory?
Learn how to find out if the file is actually a directory.
如何检查文件是否为目录?了解如何确定文件是否实际上是目录。
- File Last Modified Date in Java
Find out how to get last modified date of a file in java.
用Java文件上次修改日期了解如何在Java中获取文件的最后修改日期。
- Java FileNameFilter Example
Learn how to use FileNameFilter to list files with specific extension in java.
Java FileNameFilter示例了解如何使用FileNameFilter在Java中列出具有特定扩展名的文件。
- Java File Path, Absolute Path and Canonical Path Explained
Learn the difference between different types of file paths in java.
Java文件路径,绝对路径和规范路径介绍了解Java中不同类型的文件路径之间的区别。
- Java File Permissions
Learn how to get the file permissions for the application user in java program and how to set permissions using File class.
Java文件权限了解如何在Java程序中获取应用程序用户的文件权限,以及如何使用File类设置权限。
- How to set File Permissions in Java Easily using Java 7 PosixFilePermission
Learn the pitfalls of using File class to set permissions and why Java 7 PosixFilePermission are the best way to set file permissions in java.
如何使用Java 7 PosixFilePermission轻松在Java中设置文件权限了解使用File类设置权限的陷阱,以及为什么Java 7 PosixFilePermission是在Java中设置文件权限的最佳方法。
- Copy File in Java
Learn how to copy file using Stream, FileChannel, Apache Commons IO and Java 7 Files class and which is the best way to copy file in java.
用Java复制文件了解如何使用Stream,FileChannel,Apache Commons IO和Java 7 Files类复制文件,这是在Java中复制文件的最佳方法。
- Open File in Java
Learn how to open a file in associated application using java.awt.Desktop class.
用Java打开文件了解如何使用java.awt.Desktop类在关联的应用程序中打开文件。
- Read File in Java
Learn how to read file using FileReader, BufferedReader, Scanner class and Java 7 Files class and find out how to get encoding support and best way to read file in java.
用Java读取文件了解如何使用FileReader,BufferedReader,Scanner类和Java 7 Files类读取文件,并了解如何获得编码支持以及在Java中读取文件的最佳方法。
- Java File Scanner Example
Learn how to use Scanner class to read complete file, parse a file based on regular expression and tokens.
Java文件扫描程序示例了解如何使用Scanner类读取完整文件,基于正则表达式和标记解析文件。
- Read a File to String in Java
Learn how to read the complete file into a String in java.
用Java将文件读取为字符串了解如何在Java中将完整文件读入字符串。
- Java read file line by line
Learn how to read file line by line in java, good for working with large files in java.
Java逐行读取文件了解如何在Java中逐行读取文件,非常适合在Java中处理大型文件。
- Write a File in Java
Learn how to write a file using FileWriter, BufferedWriter, Java 7 Files class and FileOutputStream and which one to choose based on your project requirements.
用Java编写文件了解如何使用FileWriter,BufferedWriter,Java 7 Files类和FileOutputStream编写文件,以及如何根据项目要求选择哪种文件。
- Append Text to File in Java
Learn how to append data to existing file in java.
在Java中将文本追加到文件了解如何在Java中将数据附加到现有文件。
- Java InputStream to File Example
Learn how to convert InputStream to file in java using OutputStream.
Java InputStream到文件的示例了解如何使用OutputStream在Java中将InputStream转换为文件。
- Java Random Access File
An example showing usage of Java RandomAccessFile to read and write data to specific index in file.
Java随机访问文件一个示例,展示了如何使用Java RandomAccessFile读取数据并将数据写入文件中的特定索引。
- Download File from URL
Learn how to download a file from URL in java program.
从URL下载文件了解如何在Java程序中从URL下载文件。
- How to write Object to File in Java
Learn how to save object to a file in java using Serialization.
如何用Java将对象写入文件了解如何使用序列化将对象保存到Java中的文件中。
- How to read Object from File in Java
Learn how to create Object from file in java using Deserialization.
如何在Java中从文件读取对象了解如何使用反序列化从Java中的文件创建对象。
- How to Compile and Run a Java Program in another Java program
A misc program showing how can we compile and run java program from another java program.
如何在另一个Java程序中编译和运行Java程序一个杂项程序,显示我们如何从另一个Java程序编译和运行Java程序。
- Java Property File and Property XML
Learn how to read and write property file and property xml files in java.
Java属性文件和属性XML了解如何在Java中读写属性文件和属性xml文件。
- Compress File or Directory using Java ZIP
In this article, you will learn how to compress a file in ZIP format, the example shows how to recursively compress a directory to ZIP format.
使用Java ZIP压缩文件或目录在本文中,您将学习如何以ZIP格式压缩文件,该示例显示了如何以递归方式将目录压缩为ZIP格式。
- Java Unzip File Example
In this article, you will learn how to decompress a zip archive.
Java解压缩文件示例在本文中,您将学习如何解压缩zip存档。
- Java GZIP Example
In this article, you will learn how to compress a file in GZIP format and then how to decompress it in Java.
Java GZIP示例在本文中,您将学习如何以GZIP格式压缩文件,然后在Java中解压缩该文件。
- Java Temp File
Java provides API to create temporary files to be used by the program, the file names are random so it’s hard to hack it. Learn how to create temp files in Java and read/write data into them.
Java临时文件Java提供了API来创建供程序使用的临时文件,文件名是随机的,因此很难对其进行破解。 了解如何在Java中创建临时文件以及如何向其中读取/写入数据。
Make sure to share it with others and bookmark it for future use.
确保与他人共享并添加书签以备将来使用。
java io教程