一个简单的文件名搜索器
近日在找工作,在网上投了不少简历,每投一个公司我就会把这个公司的介绍页面保存到一个固定文件名数组文件夹中
以便自己可以知道都向哪些公司投了简历,也能够快速的查看某个公司的信息
由于我到不同的招聘网站上投简历,而同一个公司也可能在不同网站上发布信息,这样就可能投重
为了避免这种情况,在投前就得先检查一下是否投过着家公司,我就做了个小程序检索一下
输入公司名,得到包含这个公司名的所有文件名,如果没有就不显示
如输入:中智公司
我向这公司投过简历,显示:
中国国际技术智力合作公司(中智公司)智联招聘网--个人求职--职位信息显示.files
中国国际技术智力合作公司(中智公司)智联招聘网--个人求职--职位信息显示.htm
/*
*@author irini
*/
import java.io.*;
import java.util.*;
/*
* 对已经投递简历的公司信息的相关操作
*/
public class CompanyInfoUtil {
public static void main( String[] args ){
CompanyInfoUtil ciu = new CompanyInfoUtil();
String path = "I:\\job";
String[] ss = ciu.listFile( path );
BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );
String words = null;
System.out.print( "输入公司名:" );
try{
words = br.readLine();
}catch( Exception e ){
e.printStackTrace();
}
Collection c = ciu.getName( ss, words );
System.out.println( "\n" + "包含 " + words + " 的有: " );
Iterator it = c.iterator();
String temp = null;
while( it.hasNext() ){
temp = (String)it.next();
System.out.println( temp );
}
}
/*
* 列出给定路径下的所有文件.
* @param 路径名
* @return 文件名数组
*/
public String[] listFile( String path ){
File dir = new File( path );
String[] ss = dir.list();
return ss;
}
/*
* 得到所有包含给定字符串的字符串.
* @param 文件名数组, 公司名
* @return 检索结果
*/
public Collection getName( String[] stringList, String words ){
ArrayList al = new ArrayList();
String temp = null;
for( int i=0; i<stringList.length; i++ ){
temp = stringList<i>;
int count = 0; // 原字符串中包含words中字符的个数
int index = 0; // words的索引
int len = words.length();
// 遍历字符串的每个字符
for( int j=0; j<temp.length() && index<len; j++ ){
if( temp.charAt(j) == words.charAt( index ) ){
count++; // 包含的个数加1
index++; // words的索引指向下个字符
}
// 如果原字符串完全包含给定字符串 则将其加入ArrayList
if( count == len )
al.add( temp );
}
}
return al;
}
}
以便自己可以知道都向哪些公司投了简历,也能够快速的查看某个公司的信息
由于我到不同的招聘网站上投简历,而同一个公司也可能在不同网站上发布信息,这样就可能投重
为了避免这种情况,在投前就得先检查一下是否投过着家公司,我就做了个小程序检索一下
输入公司名,得到包含这个公司名的所有文件名,如果没有就不显示
如输入:中智公司
我向这公司投过简历,显示:
中国国际技术智力合作公司(中智公司)智联招聘网--个人求职--职位信息显示.files
中国国际技术智力合作公司(中智公司)智联招聘网--个人求职--职位信息显示.htm
/*
*@author irini
*/
import java.io.*;
import java.util.*;
/*
* 对已经投递简历的公司信息的相关操作
*/
public class CompanyInfoUtil {
public static void main( String[] args ){
CompanyInfoUtil ciu = new CompanyInfoUtil();
String path = "I:\\job";
String[] ss = ciu.listFile( path );
BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );
String words = null;
System.out.print( "输入公司名:" );
try{
words = br.readLine();
}catch( Exception e ){
e.printStackTrace();
}
Collection c = ciu.getName( ss, words );
System.out.println( "\n" + "包含 " + words + " 的有: " );
Iterator it = c.iterator();
String temp = null;
while( it.hasNext() ){
temp = (String)it.next();
System.out.println( temp );
}
}
/*
* 列出给定路径下的所有文件.
* @param 路径名
* @return 文件名数组
*/
public String[] listFile( String path ){
File dir = new File( path );
String[] ss = dir.list();
return ss;
}
/*
* 得到所有包含给定字符串的字符串.
* @param 文件名数组, 公司名
* @return 检索结果
*/
public Collection getName( String[] stringList, String words ){
ArrayList al = new ArrayList();
String temp = null;
for( int i=0; i<stringList.length; i++ ){
temp = stringList<i>;
int count = 0; // 原字符串中包含words中字符的个数
int index = 0; // words的索引
int len = words.length();
// 遍历字符串的每个字符
for( int j=0; j<temp.length() && index<len; j++ ){
if( temp.charAt(j) == words.charAt( index ) ){
count++; // 包含的个数加1
index++; // words的索引指向下个字符
}
// 如果原字符串完全包含给定字符串 则将其加入ArrayList
if( count == len )
al.add( temp );
}
}
return al;
}
}
irini
2005-12-25 22:59:40
评论:0
阅读:222
引用:0
