当前位置: 代码迷 >> Web前端 >> Java写下文件到web根目录的配置文件里
  详细解决方案

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

热度:499   发布时间:2012-09-27 11:11:17.0
Java写入文件到web根目录的配置文件里
/**
 * 
 */
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 qiaole1990@sina.com
 * @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");
	}

}

  相关解决方案