import java.io.*;
class Day19_01
{
public static void main(String[] args) throws IOException
{
//writeFile();
//readFile();
//readFile_2();
readFile_3();
}
public static void writeFile()throws IOException
{
FileOutputStream fos =new FileOutputStream("fos.txt");
fos.write("abcde".getBytes());
fos.close();
}
public static void readFile()throws IOException
{
FileInputStream fis=new FileInputStream("fos.txt");
int ch=0;
while ((ch=fis.read())!=-1)
{
System.out.println((char)ch);
}
fis.close();
}
public static void readFile_2()throws IOException
{
FileInputStream fis =new FileInputStream("fos.txt");
byte[] buf=new byte[1024];
int len=0;
while ((len=fis.read(buf))!=-1)
{
System.out.println(new String(buf,0,len));
}
fis.close();
}
public static void readFile_3()throws IOException
{
FileInputStream fis =new FileInputStream("fos.txt");
int num=fis.available();
System.out.println("num="+num);
fis.close();
}
Java file类练习完毕,越写越兴奋,虽然只是看完视频写了一遍,但是还是觉得,能够自己写出来印象最深刻
|