本文实例以文件操作、字节流、字符流、序列化流模块进行归纳,输入输出流同理部分缺省。
文件操作
java.io.File
1 | public class FileDemo { |
1 | public class FileDemo2 { |
1 | public class FileDemo3 { |
1 | public class FileDemo4 { |
字节流
java.io.FileOutputStream
1 | public class FileOutDemo { |
1 | try { |
java.io.FileInputStream
1 | public class FileInputDemo { |
1 | //默认的相对路径:就是我们的项目路径 |
java.io.DataOutputStream
1 | public class DosDemo { |
java.io.DataInputStream
1 | public class DisDemo { |
java.io.ByteArrayOutputStream
1 | File file=new File("a.txt"); |
1 | ByteArrayOutputStream bos=new ByteArrayOutputStream(); |
java.io.PrintStream
1 | FileOutputStream fos=new FileOutputStream("e:/test.txt"); |
1 | public class PrintStreamDemo { |
字符流
java.io.FileWriter
1 | public class FrAndFwDemo { |
java.io.FileReader
1 | try { |
java.io.BufferedWriter
1 | public class BrAndBwOrPwDemo { |
java.io.OutputStreamWriter
1 | public class IsrAndOswDemo { |
java.io.PrintWriter
1 | public class PrintWriterDemo { |
序列化流
java.io.RandomAccessFile
1 | public class RafDemo { |
1 | public class RafReadDemo { |
1 | public class RandomAccessFileSeriaDemo { |
java.io.ObjectOutputStream
1 | public class Student implements Serializable{ |
1 | public class ObjectSeriaDemo1 { |
1 | public class ObjectSeriaDemo2 { |