⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 savenote.java

📁 页面抓取新闻并自动生成网页的代码 有兴趣的可以看看,很有意思的东西
💻 JAVA
字号:
package admin;
import java.io.*;
import java.util.Date;
import java.text.SimpleDateFormat;

public class SaveNote {
	private String author="";
  private String title="";
  private String keywords="";
  private String content="";
  private String updateTime="";
  private String filePath="";
  private String dirPath="";
  private String templateContent="";
  private String htmlName="";
  private String saveStr="";
  private String fileSize="";
  private String saveDirectory="";
  
  public void setElement(String dirPath,String keywords,String title,String updateTime,String content,String userName,String filePath,String saveDirectory){
  	this.dirPath=dirPath;
  	this.keywords=keywords;
  	this.title=title;	
  	this.updateTime=updateTime;
  	this.content=content;
  	this.author=userName;
  	this.filePath=filePath;
  	this.saveDirectory=saveDirectory;
  	}
  public String getSaveDircetory(){ //得到html的保存目录
  	return saveDirectory;
  	}
  public String getHtmlName(){ //得到html的保存名
  	return htmlName;
  	}	
  public String getTemplateContent(){ //得到文章内容
  	return templateContent;
  	}  	  	
  	
  public void setTemplateContent() throws Exception{//替换模块中的相应内容
    String myTime=new java.text.SimpleDateFormat("yyMMddHHmmssS").format(new java.util.Date());
    htmlName=myTime+".html";  	
  	FileInputStream fileinputstream = new FileInputStream(filePath);//读取模块文件
    int lenght = fileinputstream.available();
    byte bytes[] = new byte[lenght];
    fileinputstream.read(bytes);
    fileinputstream.close();
    templateContent = new String(bytes);
    //替换模块中的相应内容
    templateContent=templateContent.replaceAll("###keywords###",keywords);
    templateContent=templateContent.replaceAll("###title###",title);
    templateContent=templateContent.replaceAll("###fileSize###",fileSize);
    templateContent=templateContent.replaceAll("###otime###",updateTime);
    templateContent=templateContent.replaceAll("###ArticleContent###",content);
    templateContent=templateContent.replaceAll("###fileName###",keywords);
    templateContent=templateContent.replaceAll("###author###",author);
    }
  public void saveHtmlFile()  throws Exception{
    String fileName = dirPath+"content/"+saveDirectory+"/"+htmlName;//生成的html文件保存路径
    FileOutputStream fileoutputstream = new FileOutputStream(fileName);//建立文件输出流
    byte tag_bytes[] = templateContent.getBytes();
    fileoutputstream.write(tag_bytes);
    fileoutputstream.close();
  	}	
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -