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;
    }
     
  • 相关阅读:
    Merge Two Sorted Lists
    4Sum
    Letter Combinations of a Phone Number
    3Sum Closest
    3Sum
    Longest Common Prefix
    Roman to Integer
    Integer to Roman
    Container With Most Water
    Regular Expression Matching
  • 原文地址:https://www.cnblogs.com/Amos-Turing/p/7923243.html
Copyright © 2011-2022 走看看