闲的无聊,随手写个小代码如下:
public static void main(String[] args) { InputStream stream = System.in; try { FileOutputStream outStream = new FileOutputStream("E:/a.txt"); byte [] data = new byte[2]; int pos = 0; while (pos != -1) { pos = stream.read(data); outStream.write(data); int size = stream.available(); System.out.println("currut pos------------"+pos); System.out.println("available size------------"+size); } outStream.flush(); outStream.close(); } catch (IOException e) { e.printStackTrace(); } try { System.out.println("========closed=============="); stream.close(); } catch (IOException e) { e.printStackTrace(); } }
问题一:输入12345会输出什么结果?
问题二:E:/a.txt中会有输入的12345保存吗?
问题三:"========closed=============="这句话会打印出来吗?
每回答一个问题说明理由,回答问题的前提是不要运行此程序,回答完再运行~