类的操作

文件的创建:new File(String文件名)

            new File(String 父路径,String 子路径)

            new File(File 父路径对象,String 子路径字符串)

FileInputStream类

FileInputStream(String name):使用给定的文件名name创建一个FileInputStream类对象

FileInputStream(File file):使用File对象创建FileInputStream对象

FileoutputStream类方法与FileInputStream类相同

FileReader与FileWriter类

        FileReader与FileWriter字符流对应了FileInputStream与FileoutputStream类。FileReader流顺序地读取文件,只要不关闭流,每次调用reader()方法就顺序地读取源中其余内容,直到源的末尾或流被关闭,由于FileInputStream与FileoutputStream类只提供了对字节或字节数组的读取方法,汉字在文件中占用两个字节,如果使用字节流,读取不好可能出现乱码现象,而采用字符流FileReader与FileWriter类可避免此现象的发生。

原文地址:https://www.cnblogs.com/zhaoyuxiao000/p/14168970.html