http://chxkyy.iteye.com/blog/213055
http://blog.csdn.net/swandragon/article/details/4770445
- InputStream is = null;
- FileOutputStream fos = null;
- //这里对is进行赋值,略
- //...
- // 文件输出流fos
- // openFile()为自定义函数,判断文件是否存在等(略)
- String fileName = "hellostory的日志.doc";
- if(!openFile(fileName)){
- return;
- }
- try {
- fos = new FileOutputStream(fileName);
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
-
- int ch = 0;
- try {
- while((ch=is.read()) != -1){
- fos.write(ch);
- }
- } catch (IOException e1) {
- e1.printStackTrace();
- } finally{
- fos.close();
- is.close();
- }
-
BufferedReader bf = new BufferedReader(
new InputStreamReader(in));
String s = null;
while ((s=bf.readLine()) != null) System.out.println(s);