zoukankan      html  css  js  c++  java
  • 多次向文件结尾写入数据

    package shi;
    
    import java.io.*;
    
    public class suiji {
    
    	/**
    	 * @param args
    	 * @throws IOException 
    	 */
    	public static void main(String[] args) throws IOException {
    		RandomAccessFile raf=null;
    		File f=new File("F:/test/123.txt");
    		try {
    			raf=new RandomAccessFile(f,"rw");
    //			seek跳过文件本身的长度,向结尾处写入
    			raf.seek(f.length());			
    			byte[]b="
    外星的小EZ你好啊".getBytes();
    			raf.write(b);                  
    			
    		} catch (FileNotFoundException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}finally{
    			if(raf!=null){
    				raf.close();
    			}
    		}
    	}
    
    }
    
  • 相关阅读:
    django配置日志
    drf6
    drf4
    drf3
    drf2
    drf1
    vue2
    vue3
    vue1
    choices字段、mtv和mvc模型、ajax基本语法、sweetalert弹出框插件、自定义分页器
  • 原文地址:https://www.cnblogs.com/xiaoqisfzh/p/4703878.html
Copyright © 2011-2022 走看看