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

写txt资料

2012-12-19 
写txt文件/** * 写文件 ** @param list * @param dstPathName */public static void writerText(List list

写txt文件

/** * 写文件 *  * @param list * @param dstPathName */public static void writerText(List list, String dstPathName) {File file = new File(dstPathName);// 存在就覆盖,不存在就新建if (file.exists()) {file.delete();try {file.createNewFile();} catch (IOException e) {e.printStackTrace();}} else {try {file.createNewFile();} catch (IOException e) {e.printStackTrace();}}try {FileOutputStream out = new FileOutputStream(file, false);for (int i = 0; i < list.size(); i++) {out.write(list.get(i).toString().getBytes());out.write("\n".getBytes());}} catch (FileNotFoundException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}}

热点排行