首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

BufferedReader跟BufferedOutputStream之间的灵活应用【回钦波】

2012-08-25 
BufferedReader和BufferedOutputStream之间的灵活应用【回钦波】package logimport java.io.BufferedOutput

BufferedReader和BufferedOutputStream之间的灵活应用【回钦波】

package log;

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

public class ReadProperties {
?static BufferedReader br = null;
?static FileReader fr = null;
?
?public static void main(String args[]){
??
??try {
???br = new BufferedReader(new FileReader("log.properties"));??//这里最好用? ./log.properties
???
??} catch (FileNotFoundException e) {
???// TODO Auto-generated catch block
???e.printStackTrace();
??}

?

?

??Properties properties = new Properties();
??try {
???properties.load(br);
???String file_path=properties.getProperty("log_path");
???System.out.println(file_path);
???
???
??//?BufferedOutputStream bo = new BufferedOutputStream(new FileOutputStream(file_path));

?

????? PrintStream bo = new PrintStream(new FileOutputStream(file_path),true);?? //printStream可以用println方?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? //法来输出字符串
????? bo.println("welcome come to huiqinbo.com");


??} catch (IOException e) {
???// TODO Auto-generated catch block
???e.printStackTrace();
??}
//??
//??return true;
?}
?

}

?

?

?

?

1. //配置文件放在了项目的根目录底下

??? log.properties

?

??? log_path?? = .\\log1.txt

?

?

2.在项目底下的log1.txt文件中查看内容:

?? welcome come to huiqinbo.com

?

?

?

?

?

?

?

?

?

热点排行