易网时代-编程资源站
Welcome
微信登录
编程资源
图片资源库
蚂蚁家优选
PDF转换器
软件资源
软件开发
、
小程序制作
、
系统集成与运维
、
空间租用
、
硬件开发
、
视频监控
、
技术咨询与支持
——联系电话:0311-88999002/88999003
首页
/
操作系统
/
Linux
/
Java日志处理 一次写入一行字符
Java日志处理 一次写入一行字符
/**
* @param path文件地址
* @param append是否追加
* @param value写入值
* @param charsetName字符集名称eg:[gb2312]
* @throws IOException
*/
public
static
void
writerLine(String path,
boolean
append,String value,String charsetName)
throws
IOException
{
OutputStreamWriter osw=
null
;
BufferedWriter bw=
null
;
try
{
osw=
new
OutputStreamWriter(
new
FileOutputStream(path,append),charsetName);
bw=
new
BufferedWriter(osw);
bw.write(
new
Date().toLocaleString()+value);
bw.newLine();
bw.flush();
}
catch
(UnsupportedEncodingException e) {
System.out.println(
"没有指定的字符集"
);
e.printStackTrace();
}
catch
(FileNotFoundException e) {
System.out.println(
"没有指定的文件"
);
e.printStackTrace();
}
catch
(IOException e) {
e.printStackTrace();
throw
new
IOException(
"IOException"
);
}
finally
{
bw.close();
osw.close();
}
}
收藏该网址
版权所有©石家庄振强科技有限公司2024
冀ICP备08103738号-5
网站地图