[java]代码库/**
* 向指定路径的文本中写入数据
*
* @param path
* 文本路径
* @param text
* 需要写入的内容
* @return true表示成功,false表示失败
*/
public static boolean writeToFileByPath(String path, String text) {
if (null == path || null == text) {
return false;
}
File file = new File(path);
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
OutputStreamWriter writer = null;
BufferedWriter bw = null;
try {
writer = new OutputStreamWriter(new FileOutputStream(file), "gbk");
bw = new BufferedWriter(writer);
bw.write(text);
return true;
} catch (Exception e) {
e.printStackTra