问个java小问题
import java.io.InputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
public class InputStreamdemo01 {
public static void main(String[] args){
// 实例化一个文件,准备从其中读取数据
File file = new File("F:" + File.separator + "source.txt");
InputStream input = null;
OutputStream out = null;
String s = new String();
int count = input.available();
byte[] b = new byte[count];
try {
input = new FileInputStream(file);
out = System.out;
input.read(b);
out.write(b);
input.close();
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
我想用int count = input.available();
取得文件里长度为什么取不到
[解决办法]
贴错代码了吧?
InputStream input = null;
OutputStream out = null;
String s = new String();
int count = input.available();
这块应该空指针了