package com.characte.main;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
public class JavaHotKeyChecker {
@SuppressWarnings("rawtypes")
private static ArrayList result = new ArrayList();
@SuppressWarnings("unchecked")
private static void recursiveSearch(File rootDir, String suffix) {
File[] files = rootDir.listFiles();
if (files != null)
for (int i = 0; i < files.length; i++) {
if (files[i].isFile() && files[i].getName().endsWith(suffix))
result.add(files[i]);
recursiveSearch(files[i], suffix);
}
}
@SuppressWarnings({ "static-access", "rawtypes" })
static public void main(String[] str) throws Exception {
File f = null;
String fileName = "/Users/admin-mac/Documents/client/Mc/Classes";
f = new File(fileName);
recursiveSearch(f, ".cpp");
File[] roots = f.listRoots();
for (int i = 0; i < roots.length; i++) {
if (result.size() > 0) {
for (int j=0 ;j<result.size();j++) {
System.out.println(j+"--&"+result.get(j));
String path =String.valueOf(result.get(j));
// System.out.println("++++"+path);
String[] nums = writeToDat(path);
for(int x=0;x<nums.length;x++){
// System.out.println(nums[x]);
}
}
} else {
System.out.println("No match on " + roots[i]);
}
}
}
public static String[] writeToDat(Object object)
{
File file = new File(object.toString().trim());
List list = new ArrayList();
String[] nums = null;
try {
FileInputStream fis = new FileInputStream(file);
InputStreamReader isr = new InputStreamReader(fis,"UTF-8"); //指定以UTF-8编码读入
BufferedReader bw = new BufferedReader(isr);
// FileOutputStream out = new FileOutputStream("");//创建输出流
File filname = new File("/Users/admin-mac/Documents/char.txt");
DataOutputStream os = new DataOutputStream(new FileOutputStream(filname));
byte[] buf=new byte[1024];
String line = null;
//因为不知道有多少数据,所以先存入list集合中
while((line = bw.readLine()) != null){
int num = line.indexOf("setString("+"");// 获得s所在的下标,
// 让后看你要的应该是s开始到di8个
if (num != -1) {
String str = null;
try {
str = line.substring(num, num + 500);
} catch (Exception e) {
str = line.substring(num);
}
os.writeChars(str+"\n");
//System.out.println(str);//
}
int num2 = line.indexOf("setMessageBox("+"");// 获得s所在的下标,
// 让后看你要的应该是s开始到di8个
if (num2 != -1) {
String str = null;
try {
str = line.substring(num2, num2 + 500);
} catch (Exception e) {
str = line.substring(num2);
}
os.writeChars(str+"\n");
//System.out.println(str);//
}
list.add(line);
}
bw.close();
} catch (IOException e) {
e.printStackTrace();
}
//确定数组长度
nums = new String[list.size()];
for(int i=0;i<list.size();i++){
String s = (String) list.get(i);
nums[i] = s;
}
return nums;
}
}