Usage of BufferedInputStream

前端 未结 5 1868
误落风尘
误落风尘 2020-12-07 23:03

Let me preface this post with a single caution. I am a total beginner when it comes to Java. I have been programming PHP on and off for a while, but I was ready to make a

5条回答
  •  既然无缘
    2020-12-07 23:15

        import java.io.*;
        class BufferedInputStream
        {
                public static void main(String arg[])throws IOException
                {
                    FileInputStream fin=new FileInputStream("abc.txt");
                    BufferedInputStream bis=new BufferedInputStream(fin);
                    int size=bis.available();
                    while(true)
                    {
                            int x=bis.read(fin);
                            if(x==-1)
                            {
                                    bis.mark(size);
                                    System.out.println((char)x);
                            }
                    }
                            bis.reset();
                            while(true)
                            {
                                    int x=bis.read();
                                    if(x==-1)
                                    {
                                        break;
                                        System.out.println((char)x);
                                    }
                            }
    
                }
    
        }
    

提交回复
热议问题