zoukankan      html  css  js  c++  java
  • Java第六次上机

    package daima;
    import java.io.*;
    public class transmit {
     public static void main(String[] args) throws IOException{
      File file=new File("data.text");
      System.out.println("文件是否存在?"+file.exists());
     try{
      if(!file.exists()){
       boolean b=file.createNewFile();
       System.out.println("文件是否创建成功?"+b);
       if(b==true){
        System.out.println("文件路径为:"+file.getAbsolutePath());
       }
      } 
     }catch(Exception e){
      System.out.println("文件创建中出现错误!");
     } 
       String str ="12345abcdef@#%&*软件工程";
       FileOutputStream fos=new FileOutputStream("data.text");
       byte[] buff=str.getBytes();
       fos.write(buff);
       fos.close();
       FileInputStream fis=new FileInputStream(file);
       byte[] buf=new  byte[(int)file.length()];
       fis.read(buf);
       String s=new String(buf);
       System.out.println(s);
       fis.close();
     }}
     

     

    这次上级分清楚了输入流以及输出流还有read、write类

    输入输出流难以理解    最应分清的是以谁为参照

  • 相关阅读:
    bzoj2438
    bzoj3040
    [AHOI2009]维护序列
    [JSOI2008]最大数
    洛谷3378堆模板
    洛谷1439
    洛谷2756
    bzoj1016
    洛谷1875
    [模板] 强连通分量
  • 原文地址:https://www.cnblogs.com/lusilin/p/11050644.html
Copyright © 2011-2022 走看看