java io教程_Java IO教程

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)

  1. 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 ”系统属性来使我们的程序平台独立。

  2. 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中删除文件或空目录,请注意,即使目录不为空且未删除,删除也不会引发任何异常。

  3. Java File separator, separatorChar, pathSeparator, pathSeparatorChar Explained with Example

    Learn about the four separator static variables of File class.

    Java文件分隔符,separatorChar,pathSeparator,pathSeparatorChar用示例解释

    了解File类的四个分隔符静态变量。

  4. How to delete non empty directory in Java

    A recursive program to delete non-empty directories in java.

    如何在Java中删除非空目录

    删除Java中非空目录的递归程序。

  5. 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中的其他目录。

  6. File Size in Java

    Learn how to get the file size in java program.

    Java中的文件大小

    了解如何在Java程序中获取文件大小。

  7. 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中获取文件扩展名。

  8. Check File Exists in Java

    Learn how to check if file exists or not in java.

    检查Java中文件是否存在

    了解如何在Java中检查文件是否存在。

  9. How to check if File is Directory?

    Learn how to find out if the file is actually a directory.

    如何检查文件是否为目录?

    了解如何确定文件是否实际上是目录。

  10. File Last Modified Date in Java

    Find out how to get last modified date of a file in java.

    用Java文件上次修改日期

    了解如何在Java中获取文件的最后修改日期。

  11. Java FileNameFilter Example

    Learn how to use FileNameFilter to list files with specific extension in java.

    Java FileNameFilter示例

    了解如何使用FileNameFilter在Java中列出具有特定扩展名的文件。

  12. Java File Path, Absolute Path and Canonical Path Explained

    Learn the difference between different types of file paths in java.

    Java文件路径,绝对路径和规范路径介绍

    了解Java中不同类型的文件路径之间的区别。

  13. 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类设置权限。

  14. 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中设置文件权限的最佳方法。

  15. 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中复制文件的最佳方法。

  16. Open File in Java

    Learn how to open a file in associated application using java.awt.Desktop class.

    用Java打开文件

    了解如何使用java.awt.Desktop类在关联的应用程序中打开文件。

  17. 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中读取文件的最佳方法。

  18. 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类读取完整文件,基于正则表达式和标记解析文件。

  19. Read a File to String in Java

    Learn how to read the complete file into a String in java.

    用Java将文件读取为字符串

    了解如何在Java中将完整文件读入字符串。

  20. 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中处理大型文件。

  21. 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编写文件,以及如何根据项目要求选择哪种文件。

  22. Append Text to File in Java

    Learn how to append data to existing file in java.

    在Java中将文本追加到文件

    了解如何在Java中将数据附加到现有文件。

  23. Java InputStream to File Example

    Learn how to convert InputStream to file in java using OutputStream.

    Java InputStream到文件的示例

    了解如何使用OutputStream在Java中将InputStream转换为文件。

  24. Java Random Access File

    An example showing usage of Java RandomAccessFile to read and write data to specific index in file.

    Java随机访问文件

    一个示例,展示了如何使用Java RandomAccessFile读取数据并将数据写入文件中的特定索引。

  25. Download File from URL

    Learn how to download a file from URL in java program.

    从URL下载文件

    了解如何在Java程序中从URL下载文件。

  26. How to write Object to File in Java

    Learn how to save object to a file in java using Serialization.

    如何用Java将对象写入文件

    了解如何使用序列化将对象保存到Java中的文件中。

  27. How to read Object from File in Java

    Learn how to create Object from file in java using Deserialization.

    如何在Java中从文件读取对象

    了解如何使用反序列化从Java中的文件创建对象。

  28. 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程序。

  29. Java Property File and Property XML

    Learn how to read and write property file and property xml files in java.

    Java属性文件和属性XML

    了解如何在Java中读写属性文件和属性xml文件。

  30. 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格式。

  31. Java Unzip File Example

    In this article, you will learn how to decompress a zip archive.

    Java解压缩文件示例

    在本文中,您将学习如何解压缩zip存档。

  32. 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中解压缩该文件。

  33. 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.

确保与他人共享并添加书签以备将来使用。

翻译自: https://www.journaldev.com/942/java-io-tutorial

java io教程

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值