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类

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

  • 相关阅读:
    linux系统安装CRT上传插件
    一些常用的vim编辑器快捷键:
    IDS 源镜像端口添加
    查看windows、linux的SN
    Tomcat安装
    puppet配置问题统计
    使用puppet
    安装puppet
    XML 生成一个XML文件
    winform 重新启动程序(重新登录)
  • 原文地址:https://www.cnblogs.com/lusilin/p/11050644.html
Copyright © 2011-2022 走看看