public class TrackGpsByLineCarGZL_AppendSchedule {
private List<File> fileListIn = new ArrayList<File>();
private static final DecimalFormat DF_DOUBLE = new DecimalFormat("##0.00###");
private List linelist=new ArrayList();
private HashMap allLine=new HashMap();
public String IN_DIR = "";
public String OUT_FILE = "E:\\调度追加\\";
String str = "";
private final String IN_ENCODE = "GBK";
private final String OUT_ENCODE = "GBK";
public static String getRandomFileName() {
SimpleDateFormat simpleDateFormat;
simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
Date date = new Date();
String str = simpleDateFormat.format(date);
System.out.println(str);
return str;// 当前时间
}
public TrackGpsByLineCarGZL_AppendSchedule()
{
}
public static final Comparator<File> SortByFileNameAsc = new Comparator<File>() {
public int compare(File f1, File f2) {
return f1.getName().compareTo(f2.getName());
}
};
public void execute() {
try {
Collections.sort(fileListIn, SortByFileNameAsc);
int count=0;
for (File file : fileListIn) {
if (file.getName().equals(".svn"))
continue;
executeAll(file);
count++;
if(count%100==0)
{
outAllLineA();
}
}
outAllLineA();
} catch (Exception ex) {
System.out.println("zyw" + ex.toString());
}
}
public void outAllLineA()
{
String temStrG = "";
File Schedule=new File("e:\\调度\\"+str+".csv");
ArrayList list=new ArrayList();
try {
BufferedReader brIn = new BufferedReader(new InputStreamReader(
new FileInputStream(Schedule), IN_ENCODE));
while ((temStrG = brIn.readLine()) != null) {
boolean isneedLine=false;
String [] line=temStrG.split("\\,");
if(allLine.containsKey(line[2]))
{
temStrG+=allLine.get(line[2]);
}
list.add(temStrG);
}
brIn.close();
} catch (IOException e) {
e.printStackTrace();
}
ArrayList list2=new ArrayList();
OperatorFile.writeFileList(OUT_FILE, "大调度2015-"+str+"_追加上传车辆.csv", list,OUT_ENCODE);
//OperatorFile.writeFileList(OUT_FILE, "JCDB_8613436741030_PS20140303.txt", list,OUT_ENCODE);
allLine.clear();
}
public void executeAll(File fileIn) {
String temStrG = "";
try {
BufferedReader brIn = new BufferedReader(new InputStreamReader(
new FileInputStream(fileIn), IN_ENCODE));
//
while ((temStrG = brIn.readLine()) != null) {
boolean isneedLine=false;
String [] line=temStrG.split("\\,");
if(!allLine.containsKey(line[1]))
allLine.put(line[1], ","+line[0]);
}
brIn.close();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(fileIn.getName()+"---------OK");
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
TrackGpsByLineCarGZL_AppendSchedule obj=new TrackGpsByLineCarGZL_AppendSchedule();
obj.execute();
}
} |
|