package com.resume.sky;
import java.io.*;
import java.util.Vector;
/**
* 获得最新的下载信息文件
* @author qKF9319
*
*/
public class SearchResultFile {
private final static String path=System.getProperty("user.home")+"//Local Settings//Temporary Internet Files//Content.IE5";
public String getTheLatestResFile(String condition)
{
Vector<File> nameList = new Vector<File>(); // 候选文件集合Result[*].htm形式
String res="";
File searchPath=new File(path);
//返回一个字符串数组,这些字符串指定此抽象路径名表示的目录中的文件和目录。
String[] tempDir=searchPath.list();
File searchDir;
for(int i=0;i<tempDir.length;i++)
{
searchDir=new File(path+"//"+tempDir[i]); //待搜索文件夹
if(searchDir.isDirectory()){
//创建带通配符的文件名过滤器对象
FilenameFilter filter = new DirFilter(condition);
File tempRes;
String[] str = searchDir.list(filter); //列出带过滤器的文件名清单
for (int j=0;j<str.length;j++)
{
tempRes=new File(searchDir.getAbsolutePath()+"//"+str[j]);//候选文件
nameList.add(tempRes);
}
}
}
if(!nameList.isEmpty())
{
long latestModifyDate=0;//获取最新修改时间
int index=0;
for(int i=0;i<nameList.size();i++)
{
if(nameList.elementAt(i).lastModified()>latestModifyDate)
{
latestModifyDate=nameList.elementAt(i).lastModified();
index=i;
}
}
res=nameList.elementAt(index).getAbsolutePath();
}
return res;
}
/**
* 获得候选文件集
* @param condition
* @return
*/
public Vector<File> getResContentFile(String condition)
{
Vector<File> nameList = new Vector<File>(); // 候选文件集合DetailSingle[*].htm形式
File searchPath=new File(path);
//返回一个字符串数组,这些字符串指定此抽象路径名表示的目录中的文件和目录。
String[] tempDir=searchPath.list();
File searchDir;
for(int i=0;i<tempDir.length;i++)
{
searchDir=new File(path+"//"+tempDir[i]); //待搜索文件夹
if(searchDir.isDirectory()){
//创建带通配符的文件名过滤器对象
FilenameFilter filter = new DirFilter(condition);
File tempRes;
String[] str = searchDir.list(filter); //列出带过滤器的文件名清单
for (int j=0;j<str.length;j++)
{
tempRes=new File(searchDir.getAbsolutePath()+"//"+str[j]);//候选文件
nameList.add(tempRes);
}
}
}
return nameList;
}
/**
* 得到具体简历信息
* @param selItem 待查看的简历的ID数组(即存放的不同简历的标识号ID)
* @param fileName 查找的文件名特征
* @throws IOException
*/
public Vector<File> getResumeContent(String[] selItem,String fileName) throws IOException
{
Vector<File> res=new Vector<File>();
Vector<File> fCollection=getResContentFile(fileName);
Vector<File> tempCollection=new Vector<File>(1);
for(int i=0;i<selItem.length;i++)
{
int num=0;
for(int j=0;j<fCollection.size();j++)
{
ParseTxtContent ptContent = new ParseTxtContent();
if(fCollection.elementAt(j)!=null)
{
InputStream is = new FileInputStream(fCollection.elementAt(j));
String readRes = ptContent.readToBuffer(is);
if(readRes.contains(selItem[i]))
{
tempCollection.add(fCollection.elementAt(j));
fCollection.setElementAt(null, j);
num++;
}
}
}
if(num>1)//找到同ID但最新更改的文件
{
long latestModifyDate=0;//获取最新修改时间
int index=0;
for(int j=0;i<tempCollection.size();j++)
if(tempCollection.elementAt(j).lastModified()>latestModifyDate)
index=j;
res.add(tempCollection.elementAt(index));
}
else
res.add(tempCollection.elementAt(0));
tempCollection.removeAllElements();
}
return res;
}
/**
* 文件类型过滤类
*/
class DirFilter implements FilenameFilter
{
private String prefix="",suffix=""; //文件名的前缀、后缀
public DirFilter(String filterstr)
{
int i = filterstr.indexOf('*');
int j = filterstr.indexOf('.');
if (i>0)
prefix = filterstr.substring(0,i);
if (j>0)
suffix = filterstr.substring(j+1);
}
public boolean accept(File dir, String filename)
{
boolean yes = true;
try
{
yes = (filename.startsWith(prefix))&(filename.endsWith(suffix));
}
catch(NullPointerException e)
{
e.printStackTrace();
}
return yes;
}
}
}
-------------------------------------------
package com.resume.sky;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import javax.swing.*;
/**
* 简历保存打开类
* @author qKF9319
*
*/
public class SelefDefFileChooser extends JFileChooser {
ParseTxtContent ptContent = new ParseTxtContent();
public SelefDefFileChooser(){}
public SelefDefFileChooser(File dir)
{
super(dir);
}
public int storeSelection(String text) {
try {
if (getDialogType() == SAVE_DIALOG) {
File outPutFile = getSelectedFile();
if (getSelectedFile().exists()) {
int app = JOptionPane.showConfirmDialog(this,
"文件已经存在,是否覆盖?", "警告", JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE);
if (app != JOptionPane.YES_OPTION)
return -1;
}
ptContent.writeFromBuffer(text,
new FileOutputStream(outPutFile));
// 用户单击 Approve 按钮(默认情况下标有 "Open" 或 "Save")时由 UI 调用此方法。
//super.approveSelection();
}
} catch (Exception e) {
e.printStackTrace();
JOptionPane.showMessageDialog(this, "文件操作错误!");
return -1;
}
return 1;
}
}
------------------------------------------------------
package com.resume.sky;
import java.awt.Font;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.swing.JLabel;
import javax.swing.JPanel;
/**
* 动态时间显示类
* @author
*
*/
public class ShowTimePanel extends JPanel {
public ClockThread clockThread = new ClockThread();
private boolean isShowing = false;
private JLabel label = new JLabel("下载耗时: ");
private JLabel showTimeLabel = new JLabel("0:00:00");
private JLabel numLabel = new JLabel(" 当前下载数: ");
private JLabel showNumLabel = new JLabel("0");
public ShowTimePanel()
{
jbInit();
}
public void jbInit() {
label.setFont(new Font("楷体", Font.BOLD, 12));
showTimeLabel.setFont(new Font("宋体", Font.PLAIN, 12));
this.add(label);
this.add(showTimeLabel);
this.add(numLabel);
this.add(showNumLabel);
}
public void setShowing(boolean isShowing) {
this.isShowing = isShowing;
}
public boolean getShowing() {
return isShowing;
}
public void resetLabelText()
{
showTimeLabel.setText("0:00:00");
}
public void resetNumLabelText()
{
showNumLabel.setText("0");
}
public void setNumLabelText(String num)
{
showNumLabel.setText(num);
}
public class ClockThread extends Thread
{
Calendar calendar = new GregorianCalendar();
long hOneTime=3600000;
public void run()
{
SimpleDateFormat dateFormat = new SimpleDateFormat("mm:ss");
long standardTime = new Date().getTime();
long runT;
while (isShowing)
{
runT=new Date().getTime()-standardTime;
//calendar.setTime(new Date(runT));
//calendar.set(Calendar.SECOND, calendar.get(Calendar.SECOND));
//showTimeLabel.setText(dateFormat.format(calendar.getTime()));
showTimeLabel.setText(runT/hOneTime+":"+dateFormat.format(new Date(runT)));
//System.out.println(dateFormat.format(new Date(0)));//08:00:00 why
try
{
Thread.sleep(1000); //休息一秒
}
catch(InterruptedException e)
{
e.printStackTrace();
}
}
}
}
}
-----------------------------------------------------
package com.resume.sky;
import javax.swing.tree.*;
import java.util.*;
import javax.swing.*;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
public class TreeModel extends JFrame{
int cont=1;
public DefaultMutableTreeNode treeDataMode=new DefaultMutableTreeNode("root"); //定义根节点
public DefaultTreeModel model=new DefaultTreeModel(treeDataMode); //定义模型
JScrollPane jScrollPane1 = new JScrollPane();
JTree jTree1 = new JTree(model); //定义树
//设置选择模式
TreeSelectionModel sm=new DefaultTreeSelectionModel();
JPopupMenu jPopupMenu1 = new JPopupMenu();
JMenuItem jMenuItem1 = new JMenuItem();
JMenuItem jMenuItem2 = new JMenuItem();
JMenuItem jMenuItem3 = new JMenuItem();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JButton jButton3 = new JButton();
public TreeModel() {
try {
jbInit();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public static void main(String[] args) {
TreeModel tree = new TreeModel();
tree.setVisible(true);
}
private void jbInit() throws Exception {
this.setSize(500,500);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(false);
this.setTitle("JTree使用");
this.getContentPane().setLayout(null);
jScrollPane1.setVerticalScrollBarPolicy(JScrollPane.
VERTICAL_SCROLLBAR_ALWAYS);
jScrollPane1.setBounds(new Rectangle(39, 38, 163, 347));
jMenuItem1.setText("A");
jMenuItem2.setText("B");
jMenuItem3.setText("C");
jTree1.addMouseListener(new TreeModel_jTreeModel1_mouseAdapter(this));
jButton1.setBounds(new Rectangle(264, 40, 83, 25));
jButton1.setText("添加节点");
jButton1.addActionListener(new TreeModel_jButton1_actionAdapter(this));
jButton2.setBounds(new Rectangle(266, 82, 83, 25));
jButton2.setText("展开节点");
jButton2.addActionListener(new TreeModel_jButton2_actionAdapter(this));
jTree1.addTreeSelectionListener(new TreeModel_jTreeModel1_TreeModelSelectionAdapter(this));
jLabel1.setText("jLabel1");
jLabel1.setBounds(new Rectangle(221, 353, 235, 31));
jLabel2.setText("jLabel2");
jLabel2.setBounds(new Rectangle(221, 262, 232, 36));
jButton3.setBounds(new Rectangle(266, 125, 83, 25));
jButton3.setText("删除节点");
jButton3.addActionListener(new Tree_jButton3_actionAdapter(this));
this.getContentPane().add(jScrollPane1);
this.getContentPane().add(jButton1);
this.getContentPane().add(jButton2);
this.getContentPane().add(jLabel1);
this.getContentPane().add(jLabel2);
this.getContentPane().add(jButton3);
jScrollPane1.getViewport().add(jTree1);
jPopupMenu1.add(jMenuItem1);
jPopupMenu1.add(jMenuItem2);
jPopupMenu1.add(jMenuItem3);
//设置模式
sm.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
jTree1.setSelectionModel(sm);
//
}
public void viewAllNode(){ //展开树
for(Enumeration nodes=treeDataMode.breadthFirstEnumeration();nodes.hasMoreElements();){
DefaultMutableTreeNode node=(DefaultMutableTreeNode)nodes.nextElement();
jTree1.expandPath(new TreePath(node.getPath()));
}
}
public void addNode(String item){
TreePath parentPath = jTree1.getSelectionPath();
DefaultMutableTreeNode parentNode = null;
if(parentPath==null){
parentNode=treeDataMode;
}
else{
parentNode = (DefaultMutableTreeNode)
(parentPath.getLastPathComponent());
}
Object child=new String(item);
addItem(parentNode, child, true);
}
private void addItem(DefaultMutableTreeNode parent, Object child,
boolean b){
DefaultMutableTreeNode childNode =
new DefaultMutableTreeNode(child);
if (parent == null) {
parent = treeDataMode;
}
model.insertNodeInto(childNode, parent,
parent.getChildCount());
}
public void delNode(){ //删除节点
TreePath currentSelection = jTree1.getSelectionPath();
if (currentSelection != null) {
DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode)
(currentSelection.getLastPathComponent());
MutableTreeNode parent = (MutableTreeNode) (currentNode.getParent());
if (parent != null) {
model.removeNodeFromParent(currentNode);
}
}
}
public void jTree1_mouseReleased(MouseEvent e) {
if(e.isPopupTrigger()){
jPopupMenu1.show(e.getComponent(),e.getX(),e.getY());
}
}
public void myAddItem(String item){ //添加节点
TreePath tp=jTree1.getSelectionPath(); //获得路径
DefaultMutableTreeNode dmtn=null; //定义一个新节点
if(tp==null){ //判断获得的节点是否为空
dmtn=treeDataMode; //如果为空就设定新节点为根节点
}
else{
dmtn=(DefaultMutableTreeNode)(tp.getLastPathComponent());//如果不为空就设为当前节点
}
Object chil=new String(item); //定义一个新节点值
DefaultMutableTreeNode chileNode=new DefaultMutableTreeNode(chil); //定义一个新节点(用于加入到树中)
model.insertNodeInto(chileNode,dmtn,dmtn.getChildCount()); //添加节点
}
public void jButton1_actionPerformed(ActionEvent e) { //添加节点
myAddItem("节点"+cont);
cont++;
}
public void jButton2_actionPerformed(ActionEvent e) { //展开节点
viewAllNode();
}
public void jTree1_valueChanged(TreeSelectionEvent e) {
Object tp[]=e.getPath().getPath();
jLabel2.setText(tp[tp.length-1].toString()); //显示所选节点的值
StringBuffer sb=new StringBuffer();
for(int i=1;i<tp.length;i++){
sb.append(tp[i]+"/");
}
jLabel1.setText(new String(sb)); //显示所选节点所经过的路径
}
public void jButton3_actionPerformed(ActionEvent e) {
delNode();
}
}
class Tree_jButton3_actionAdapter
implements ActionListener {
private TreeModel adaptee;
Tree_jButton3_actionAdapter(TreeModel adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton3_actionPerformed(e);
}
}
class TreeModel_jButton2_actionAdapter
implements ActionListener {
private TreeModel adaptee;
TreeModel_jButton2_actionAdapter(TreeModel adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
class TreeModel_jButton1_actionAdapter
implements ActionListener {
private TreeModel adaptee;
TreeModel_jButton1_actionAdapter(TreeModel adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
class TreeModel_jTreeModel1_mouseAdapter
extends MouseAdapter {
private TreeModel adaptee;
TreeModel_jTreeModel1_mouseAdapter(TreeModel adaptee) {
this.adaptee = adaptee;
}
public void mouseReleased(MouseEvent e) {
adaptee.jTree1_mouseReleased(e);
}
}
class TreeModel_jTreeModel1_TreeModelSelectionAdapter
implements TreeSelectionListener {
private TreeModel adaptee;
TreeModel_jTreeModel1_TreeModelSelectionAdapter(TreeModel adaptee) {
this.adaptee = adaptee;
}
public void valueChanged(TreeSelectionEvent e) {
adaptee.jTree1_valueChanged(e);
}
}
-------------------------
@echo off
echo 正在清除系统垃圾文件,请稍等......
del /f /s /q "%userprofile%/Local Settings/Temporary Internet Files/*.*"
echo 清除系统垃圾完成!
echo.
exit
---------------------------
@echo off
taskkill /f /t /im IEXPLORE.EXE