/*
* Created on 2004-9-30
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
/**
* @author Administrator
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
import java.io.*;
import java.util.*;
public class Test {
public static List getTextFile(String path){
File parentFile=new File(path);
File[] childrenFile=parentFile.listFiles();
ArrayList txtFile=new ArrayList();
if(childrenFile!=null&&childrenFile.length>0){
for(int i=0;i<childrenFile.length;i++){
if(childrenFile[i].getName().endsWith(".txt"))
txtFile.add(childrenFile[i]);
}
}
return txtFile;
}
public static void copyFile(List list,String path)throws Exception{
if(list!=null&&list.size()>0){
File mkFile=new File(path);
mkFile.mkdirs();
for(int i=0;i<list.size();i++){
File file=(File)list.get(i);
// DataInputStream in=new DataInputStream(new FileInputStream(file));
BufferedReader in=new BufferedReader(new InputStreamReader(new FileInputStream(file)));
DataOutputStream out=new DataOutputStream(new FileOutputStream(path+"/"+file.getName()));
String s="";
while((s=in.readLine())!=""&&s!=null){
WriteToDB(s," ");
out.writeUTF(s);
}
in.close();
out.flush();
out.close();
}
}
}
public static void WriteToDB(String s,String flag){
String[] ss=s.split(flag);
if(ss.length>0&&ss!=null){
for(int i=0;i<ss.length;i++){
//写入Db
}
}
}
public static void main(String args[])throws Exception{
List list=getTextFile(args[0]);
if(list!=null&&list.size()>0){
for(int i=0;i<list.size();i++){
File file=(File)list.get(i);
System.out.println(file.getName());
}
}
copyFile(list,args[1]);
}
}
* Created on 2004-9-30
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
/**
* @author Administrator
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
import java.io.*;
import java.util.*;
public class Test {
public static List getTextFile(String path){
File parentFile=new File(path);
File[] childrenFile=parentFile.listFiles();
ArrayList txtFile=new ArrayList();
if(childrenFile!=null&&childrenFile.length>0){
for(int i=0;i<childrenFile.length;i++){
if(childrenFile[i].getName().endsWith(".txt"))
txtFile.add(childrenFile[i]);
}
}
return txtFile;
}
public static void copyFile(List list,String path)throws Exception{
if(list!=null&&list.size()>0){
File mkFile=new File(path);
mkFile.mkdirs();
for(int i=0;i<list.size();i++){
File file=(File)list.get(i);
// DataInputStream in=new DataInputStream(new FileInputStream(file));
BufferedReader in=new BufferedReader(new InputStreamReader(new FileInputStream(file)));
DataOutputStream out=new DataOutputStream(new FileOutputStream(path+"/"+file.getName()));
String s="";
while((s=in.readLine())!=""&&s!=null){
WriteToDB(s," ");
out.writeUTF(s);
}
in.close();
out.flush();
out.close();
}
}
}
public static void WriteToDB(String s,String flag){
String[] ss=s.split(flag);
if(ss.length>0&&ss!=null){
for(int i=0;i<ss.length;i++){
//写入Db
}
}
}
public static void main(String args[])throws Exception{
List list=getTextFile(args[0]);
if(list!=null&&list.size()>0){
for(int i=0;i<list.size();i++){
File file=(File)list.get(i);
System.out.println(file.getName());
}
}
copyFile(list,args[1]);
}
}