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

资料读取为字符串,字符串存储为文件

2012-08-26 
文件读取为字符串,字符串存储为文件将外部文件读取成为字符串public void doTask(String strPage, String

文件读取为字符串,字符串存储为文件

将外部文件读取成为字符串

public void doTask(String strPage, String basePath, ProductDownload product) {synchronized (lock) {String text = strPage;String path = basePath;String filePath = path + File.separator + "product"+ product.getProductId() + File.separator + "product.html";FileOutputStream fos = null;try {fos = new FileOutputStream(filePath);BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos));bw.write(text);bw.flush();} catch (Exception e) {e.printStackTrace();} finally {if (fos != null) {try {fos.close();} catch (Exception e) {}}}}}

?

?

热点排行