zoukankan      html  css  js  c++  java
  • 在文件写入字符串

    public static void migrationV4SQL(String menuName)   {


    try {
    RandomAccessFile rf=new RandomAccessFile(getDiskFileItem(),"rw");
    rf.seek(rf.length()); //将指针移动到文件末尾
    rf.write((BuildMenuUtils.buildSQL(menuName)+" ").getBytes()); //字符串末尾需要换行符
    rf.close();//关闭文件流
    }catch (IOException e){
    e.printStackTrace();
    }
    //
    // try {
    // FileOutputStream fos = new FileOutputStream (new File("d:\abc.txt"),true ) ;
    // String str = "ABC " ; //字符串末尾需要换行符
    // fos.write(str.getBytes()) ;
    // fos.close ();
    // } catch (IOException e) {
    // e.printStackTrace();
    // }
    //
    // try {
    // FileWriter fw = new FileWriter("d:\abc.txt",true);
    // PrintWriter pw=new PrintWriter(fw);
    // pw.println("append content"); //字符串末尾不需要换行符
    // pw.close () ;
    // fw.close () ;
    // } catch (IOException e) {
    // e.printStackTrace();
    // }
    }

    public static String getDiskFileItem(){
    String root = new StringBuilder(System.getProperty("user.dir"))
    .append(File.separator)
    .append("src")
    .append(File.separator)
    .append("main")
    .append(File.separator)
    .append("java")
    .append(File.separator)
    .append("db")
    .append(File.separator)
    .append("migration")
    .append(File.separator)
    .append("V4__.sql")
    .toString();
    return root;
    }
     
  • 相关阅读:
    16-1-6 kafka的操作
    16-1-5:MapReduce
    MapReduce概述
    MapReduce的代码实现过程分析
    MapReduce
    HDFS2—SequenceFile(小文件的解决方案)
    HDFS2—federation
    hdfs
    缓解爬虫ip被封的概率
    zookeeper集群搭建
  • 原文地址:https://www.cnblogs.com/Amos-Turing/p/7923243.html
Copyright © 2011-2022 走看看