欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Java写入文件到web根目录的配置文件里

程序员文章站 2022-07-15 08:47:05
...

/**
*
*/
package com.ape.weibo.basedata.utils;

import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

/**
* @author Happy
* @me <a href="http://www.weibo.com/qiaolevip">@快乐每一天Joe</a>
* @mail [email protected]
* @date 2012-1-31
*/
public class OperaFile {
public void writeFile(String content) {
try {
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream("./src/main/config/weibo_url.txt"),
"UTF-8"));
out.write(content);
out.newLine();
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}

public static void main(String[] args) {
OperaFile operaFile = new OperaFile();
operaFile.writeFile("jjjjjjjjjjjjjjj\r\neeeeeeee");
}

}