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

📄 testhtml.java

📁 我自己写的
💻 JAVA
字号:
import search.*;
import treeview.*;
import util.*;
import tornado.irms.util.comm.CommFunction;
import java.util.*;
import java.net.URLEncoder;
import   java.io.*;  

import tornado.irms.se.search.* ;
import tornado.irms.se.ms.* ;

public class TestHtml 
{private static String Path_caijing ;
private static String Path_keji ;
private static String Path_yule ;

public void readINI(String path)
{
	IniReader   iniReader   =   new   IniReader();
	try   
	  {   
		  iniReader.load(path);   
		  Map   sections   =   iniReader.getSections();   
		  Map   section1   =   (Map)sections.get("SYSTEM-CONFIG");   
		  //System.out.println("IRMSPath:"   +   section1.get("IRMSPath")); 
		  Path_caijing = (String)(section1.get("Path_caijing")) ;
		  Path_keji = (String)(section1.get("Path_keji")) ;
		  Path_yule = (String)(section1.get("Path_yule")) ;
	  }
	  catch   (IOException   e)   
	  {   
		  //   TODO   Auto-generated   catch   block   
		  e.printStackTrace();   
	  }   
}

private static ArrayList theFileList = new ArrayList() ;
public static void find(File file) throws Exception
{
	
	File [] temp=file.listFiles();
	for(int i=0;i<temp.length;i++)
	{
		if(temp[i].isFile())
		{
			//System.out.println("Find file:"+temp[i].getAbsolutePath());
			theFileList.add(temp[i].getAbsolutePath()) ;
		}else
		{
			find(temp[i]);
		}
	}
	
}

public static boolean getHtml(String filename) 
{
	boolean b = true;
	String filename2 = filename + "2.bak";
	BufferedReader in = null;
	BufferedWriter out = null;
	int temp ;
	boolean ifprint = false ;
	try 
	{
		in = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
		out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename2)));
		String s = in.readLine();
		while (s != null) 
		{
			String s2 = in.readLine();
			temp = s2.indexOf("<!--正文开始-->") ;
			if(temp > -1)
			{
				ifprint = true ;
			}
			temp = s2.indexOf("<!--正文内容结束-->") ;
			if(temp > -1)
			{
				ifprint = false ;
			}
			
			if(ifprint)
			{
				if (s2 == null) 
				{
					if (s.trim().length() > 0) 
					{
						out.write(s);
						out.newLine();
						out.newLine();
					}
				} 
				else 
				{
					out.write(s);
					out.newLine();
				}
			}
			
			s = s2;
		}
		out.flush();
		out.close();
		in.close();
		b = true;
	} 
	catch (Exception e) 
	{
	} 
	finally 
	{
		try 
		{
			out.close();
		} 
		catch (Exception e) 
		{
		}
		try 
		{
			in.close();
		} 
		catch (Exception e) 
		{
		}
	}

	if (!b)
		return false;

	String filename3 = filename + "3.bak";
	File iniFile = null;
	File f2 = null;
	File f3 = null;
	try 
	{
		iniFile = new File(filename);
		f2 = new File(filename2);
		f3 = new File(filename3);
		iniFile.renameTo(f3);
		while (!iniFile.exists()) 
		{
			if (f2.exists()) 
			{
				try 
				{
					f2.renameTo(iniFile);
				} 
				catch (Exception e) 
				{
				}
			} 
			else if (f3.exists()) 
			{
				try 
				{
					f3.renameTo(iniFile);
				} 
				catch (Exception e) 
				{
				}
			}
		}
	} 
	catch (Exception e) 
	{
	} 
	finally 
	{
		try 
		{
			f3.deleteOnExit();
		} 
		catch (Exception e) 
		{
		}
		try 
		{
			f2.deleteOnExit();
		} 
		catch (Exception e) 
		{
		}
	}

	if (iniFile != null && iniFile.exists())
		return true;
	return false;
}


public static void main(String arg[])
{
	
	TestHtml ld = new TestHtml() ;
	ld.readINI("./include/Config.ini") ;
	//ld.listTheDoc("julei") ;
	
	//获得所有科技类文件列表
	File caijing = new File(Path_caijing) ;
	try
	{
		find(caijing) ;
	}catch(Exception e)
	{
		System.out.println("read keji files error!");
	}
	
	for(int i = 0 ; i < theFileList.size() ; i++)
	{
		getHtml((String)(theFileList.get(i))) ;
	}
	
	
	System.out.println("main end");
}
}

⌨️ 快捷键说明

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