java file
来源:百度知道 编辑:UC知道 时间:2024/05/17 16:25:21
import java.io.*;
public class file7
{
public static void main(String[] args)throws Exception
{
File f=new File("f:\\11.txt");
FileInputStream fis=new FileInputStream(f);
FilterInputStream filter=new FilterInputStream(fis);//protected?/的存在问题
byte b[]= new byte[(int)f.length()];
System.out.print(filter.read(b));
fis.close();
}
}
问题出在哪儿
public class file7
{
public static void main(String[] args)throws Exception
{
File f=new File("f:\\11.txt");
FileInputStream fis=new FileInputStream(f);
FilterInputStream filter=new FilterInputStream(fis);//protected?/的存在问题
byte b[]= new byte[(int)f.length()];
System.out.print(filter.read(b));
fis.close();
}
}
问题出在哪儿
FilterInputStream类的构造器是protected的,只允许子类访问,所以你用FilterInputStream的子类比较合适。因为它的子类的构造器就是public的了。
例如:BufferedInputStream, DataInputStream
对,它是protected的方法,在io中,可以使用他的子类:BufferedInputStream。lz可以把代码改成:
BufferedInputStream filter = new BufferedInputStream(fis);
java file
Java.io.File
java中 File类
java file 的异常
怎么用java储存文件?(save file)
在编完JAVA程序后, 先compile file还是run application for current file
关于java io 包 File 类的问题
JAVA问题:BufferedReader file = new BufferedReader(new FileReader(path))总是出错这是为何?
java文件操作,使用file.renameTo()方法,为什么不能将文件重命名呢?
Java的File类有没有修改文件属性和判断后缀名的方法~~~