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类

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

  • 相关阅读:
    继续无题
    关于自杀的一些观点
    详解js运算符
    数据库批量 之 Oracle
    数据库批量 之 DB2
    linux压缩(解压缩)命令详解
    Cron
    解压命令
    常见web错误码
    cmd命令大全
  • 原文地址:https://www.cnblogs.com/lusilin/p/11050644.html
Copyright © 2011-2022 走看看