熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java核心技術 >> 正文

java操作將內容寫入文件

2013-11-23 19:23:36  來源: Java核心技術 

  public static boolean updateFile(String str)

  {

  str = test;

  boolean blg = false;

  try {

  BufferedWriter bw = new BufferedWriter(new FileWriter(C:\\datatxt));

  StringBuilder sb = new StringBuilder();

  sbappend(str);

  String a = sbtoString();

  byte[] b = (a)getBytes();

  // 寫入文件還可以用其他方法如write(String str)

  bwwrite(a blength);

  bwclose();

  } catch (IOException e) {

  // TODO Autogenerated catch block

  eprintStackTrace();

  }

  return blg ;

  }


From:http://tw.wingwit.com/Article/program/Java/hx/201311/26772.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.