动态获取某个网站的内容,并忘了保存怎么恢复ppt到TXT中

import java.io.BufferedR import java.io.F
import java.io.FileInputSimport java.io.FileOutputS
import java.io.FileWimport java.io.IOEimport java.io.InputStreamRimport java.io.RandomAccessF
import java.util.Aimport java.io.FileNotFoundE
public class communication {
public static void main(String[] args){
int i=0,j=0;
String content="GBK";
String filePath ="d:/lgq.txt";
readTxtFile(filePath);
String person1 = "A:";
String fileName1 ="D:/A.txt";
String fileName2 ="D:/B.txt";
String[] arrs1= new String[30];
String[] arrs2= new String[30];
String str1 = new String(); //原有txt内容
String encoding=
File file=new File(filePath);
if(file.isFile() && file.exists()){ //判断文件是否存在
InputStreamReader read = new InputStreamReader(
new FileInputStream(file),encoding);//考虑到编码格式
BufferedReader bufferedReader = new BufferedReader(read);
String lineTxt =
while((lineTxt = bufferedReader.readLine()) != null){
System.out.println(lineTxt);
if (lineTxt.contains(person1)){
arrs1[i]=lineT
arrs2[j]=lineT
System.out.println(Arrays.toString(arrs1));
System.out.println(Arrays.toString(arrs2));
read.close();
System.out.println("找不到指定的文件");
} catch (Exception e) {
System.out.println("读取文件内容出错");
e.printStackTrace();
File f1 = new File(fileName1);
createFile(fileName1);
// 建立输出字节流
FileWriter fos =
fos = new FileWriter(f1);
} catch (FileNotFoundException e) {
e.printStackTrace();
// 用FileWriter 的write方法写入字节数组
for(int tmp1=0;tmp1&arrs1.tmp1++){
if(arrs1[tmp1]!=null){
fos.write(arrs1[tmp1]);
fos.write("\r\n");
} catch (IOException e) {
e.printStackTrace();
System.out.println("写入成功");
// 为了节省IO流的开销,需要关闭
fos.close();
} catch (IOException e) {
e.printStackTrace();
}catch (IOException e){
e.printStackTrace();
System.out.println(str1);
File f2 = new File(fileName2);
createFile(fileName2);
// 建立输出字节流
FileWriter fos2 =
fos2 = new FileWriter(f2);
} catch (FileNotFoundException e) {
e.printStackTrace();
// 用FileOutputStream 的write方法写入字节数组
for(int tmp2=0;tmp2&arrs1.tmp2++){
if(arrs2[tmp2]!=null){
fos2.write(arrs2[tmp2]);
fos2.write("\r\n");
} catch (IOException e) {
e.printStackTrace();
System.out.println("写入成功");
// 为了节省IO流的开销,需要关闭
fos2.close();
} catch (IOException e){
e.printStackTrace();
catch (IOException e){
e.printStackTrace();
String a=new String [i];//
for( j=0;j&i;j++){//
if((String a[i]= bufferedReader.readLine())){
System.out.println(Arrays.toString(a));
//创建目录
String dirName = "D:/work/temp/temp0/temp1";
String dirName = "D:";//
communication.createDir(dirName);
//创建文件
String fileName = dirName + "/temp2/tempFile.txt";
//创建临时文件
String prefix = "temp";
String suffix = ".txt";
for (int i = 0; i & 10; i++) {
System.out.println("创建了临时文件:"
+ communication.createTempFile(suffix, dirName));
//在默认目录下创建临时文件
for (int i = 0; i & 10; i++) {
System.out.println("在默认目录下创建了临时文件:"
+ communication.createTempFile(p suffix, null));
* 读TXT文件内容
* @param fileName
public static void readTxtFile(String filePath){
String encoding="GBK";
File file=new File(filePath);
if(file.isFile() && file.exists()){ //判断文件是否存在
InputStreamReader read = new InputStreamReader(
new FileInputStream(file),encoding);//考虑到编码格式
BufferedReader bufferedReader = new BufferedReader(read);
String lineTxt =
while((lineTxt = bufferedReader.readLine()) != null){
System.out.println(lineTxt);
read.close();
System.out.println("找不到指定的文件");
} catch (Exception e) {
System.out.println("读取文件内容出错");
e.printStackTrace();
* 创建文件
* @param fileName
public static boolean createFile(String filename) {
File file = new File(filename);
if(file.exists()) {
System.out.println("创建单个文件" + filename + "失败,目标文件已存在!");
if (filename.endsWith(File.separator)) {
System.out.println("创建单个文件" + filename + "失败,目标文件不能为目录!");
//判断目标文件所在的目录是否存在
if(!file.getParentFile().exists()) {
//如果目标文件所在的目录不存在,则创建父目录
System.out.println("目标文件所在目录不存在,准备创建它!");
if(!file.getParentFile().mkdirs()) {
System.out.println("创建目标文件所在目录失败!");
//创建目标文件
if (file.createNewFile()) {
System.out.println("创建单个文件" + filename + "成功!");
System.out.println("创建单个文件" + filename + "失败!");
} catch (IOException e) {
e.printStackTrace();
System.out.println("创建单个文件" + filename + "失败!" + e.getMessage());
public static boolean createDir(String destDirName) {
File dir = new File(destDirName);
if (dir.exists()) {
System.out.println("创建目录" + destDirName + "失败,目标目录已经存在");
if (!destDirName.endsWith(File.separator)) {
destDirName = destDirName + File.
//创建目录
if (dir.mkdirs()) {
System.out.println("创建目录" + destDirName + "成功!");
System.out.println("创建目录" + destDirName + "失败!");
public static boolean writeTxtFile(String content,File
fileName)throws Exception{
RandomAccessFile mm=
boolean flag=
FileOutputStream o=
o = new FileOutputStream(fileName);
o.write(content.getBytes("GBK"));
o.close();
mm=new RandomAccessFile(fileName,"rw");
mm.writeBytes(content);
} catch (Exception e) {
e.printStackTrace();
if(mm!=null){
mm.close();
阅读(...) 评论()批量采集自动提取保存网页内容_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
批量采集自动提取保存网页内容
阅读已结束,下载本文需要
想免费下载更多文档?
定制HR最喜欢的简历
下载文档到电脑,同时保存到云知识,更方便管理
加入VIP
还剩5页未读,
定制HR最喜欢的简历
你可能喜欢存在动态数组CArry里面的数据怎么保存到TXT文件中_百度知道
存在动态数组CArry里面的数据怎么保存到TXT文件中
MFC中,CArry里面存储的是CPoint类型的数据。要通过线程把它存储到记事本文件中。请问要怎么做,最好有实际的编程例子。
我有更好的答案
output_file&&arr[i]; arr.Add(c);&lt,1); CPoint c(2,2); CPoint b(1;arr[i].y&lt.x&&& &&&lt.txt&); for( int i=0; i&arr.GetSize() ; arr.Add(a); ofstream output_file(& arr.Add(b); CArray&CPoint& fstream&然后在main函数里添加例子CPoint a (0,0)首先要包含必须的东西#include &quot
为您推荐:
其他类似问题
动态数组的相关知识
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。求教,在线等!!!!挺急的!!!用C从一个TXT中提取需求数据写入另一个txt文件中
[问题点数:20分]
求教,在线等!!!!挺急的!!!用C从一个TXT中提取需求数据写入另一个txt文件中
[问题点数:20分]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
2014年 总版技术专家分年内排行榜第二
2013年 总版技术专家分年内排行榜第三
2014年 总版技术专家分年内排行榜第二
2013年 总版技术专家分年内排行榜第三
匿名用户不能发表回复!|Javascript写入txt和读取txt文件示例
转载 & & 作者:
这篇文章主要介绍了Javascript写入txt和读取txt文件的方法,需要的朋友可以参考下
1. 写入 FileSystemObject可以将文件翻译成文件流。 第一步: 例:
代码如下: Var fso=new ActiveXObject(Scripting.FileSystemObject);
创建一个可以将文件翻译成文件流的对象。 第二步:用于创建一个textStream 对象 括号里边有三个属性 1. 文件的绝对路径 2. 文件的常数 只读=1,只写=2 ,追加=8 等权限。(ForReading 、 ForWriting 或 ForAppending 。); 3. 一个布尔值 允许新建则为true 相反为false; 例:
代码如下: Var f=fso.createtextfile(“C:\a.txt”,2,true);
第三步:调用textStream的方法 1. Write(不在写入数据末尾添加新换行符) 2. WriteLine(要在最后添加一个新换行符) 3. WriteBlankLines(增加一个或者多个空行) 例:
代码如下: f.writeLine(“wo shi di yi hang”);
第四步: 关闭textStream 对象: 例:f.close(); 2. 读取 第一步:
代码如下: Var fso=new ActiveXObject(Scripting.FileSystemObject);
创建一个可以将文件翻译成文件流的对象。 第二步:用于创建一个textStream 对象 括号里边有三个属性 4. 文件的绝对路径 5. 文件的常数 只读=1,只写=2 ,追加=8 等权限。(ForReading 、 ForWriting 或 ForAppending 。); 6. 一个布尔值 允许新建则为true 相反为false; 例:
代码如下: Var f=fso.opentextfile(“C:\a.txt”,1,true);
第三步:调用读取方法 1. Read(用于读取文件中指定数量的字符) 2. ReadLine(读取一整行,但不包括换行符) 3. ReadAll(则读取文本文件的整个内容); 判断是否读取到最后一行
代码如下: while (!f.AtEndOfStream) { f.Readline(); }
第四步: 关闭textStream 对象: 例:f.close(); 下面是一个html打开txt文件的例子。
代码如下: &!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"& &html xmlns="http://www.w3.org/1999/xhtml"& &head& &meta http-equiv="Content-Type" content="text/ charset=utf-8" /& &title&你好&/title& &/head& &body& &div id="aa"&&/div& &script language="javascript"& var fso, ts, var ForReading = 1; fso = new ActiveXObject("Scripting.FileSystemObject"); ts = fso.OpenTextFile("d:\\testfile.txt", ForReading); s = ts.ReadLine(); document.getElementById("aa").innerHTML=s; &/script& &/body& &/html&
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具

我要回帖

更多关于 忘了保存怎么恢复ppt 的文章

 

随机推荐