package com.jyc.filter;
import java.io.File;
import java.io.FileFilter;
import com.jyc.runnable.Runner1;
public class Test implements FileFilter{
@Override
public boolean accept(File pathname) {
String filename = pathname.getName().toLowerCase();
//System.out.println("-- "+pathname.getName());
if(filename.endsWith(".ctl")){
return true;
}else{
return false;
}
}
/*
* C:sqlldra.ctl
C:sqlldr.ctl
C:sqlldrc.ctl
C:sqlldrd.ctl
C:sqlldre.ctl
C:sqlldrf.ctl
C:sqlldrg.ctl
C:sqlldrh.ctl
*/
public static void main(String[] args) {
File file = new File("C:\sqlldr");
File[] files = file.listFiles(new Test());
for(File f : files){
System.out.println(f.getPath());
//new Thread(new Runner1(f.getPath())).start();
}
}
}
package com.jyc.runnable;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
public class Runner1 implements Runnable {
private String str;
public Runner1(String str) {
this.str = str;
}
@Override
public void run() {
//System.out.println(" = "+str); d.ctl
String cmd = "d:/db/oracle/product/10.2.0/db_2/bin/sqlldr userid=jyc/jyc@orcl control=" +
//"C:/mycontrl.ctl"
str
+" bad=c:/bad.txt";
try {
Process ldr = Runtime.getRuntime().exec(cmd);
InputStream stderr = ldr.getInputStream();
InputStreamReader isr = new InputStreamReader(stderr);
BufferedReader br = new BufferedReader(isr);
String line = null;
while ((line = br.readLine()) != null)
System.out.println("*** " + line);
stderr.close();
isr.close();
br.close();
try {
ldr.waitFor();
} catch (Exception e) {
System.out.println("process function:loader wait for != 0");
}
} catch (Exception ex) {
System.out.println("process function:loader execute exception"
+ ex.toString());
}
}
}