码迷,mamicode.com
首页 > 编程语言 > 详细

多线程

时间:2016-12-25 18:10:44      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:lld   read   runner   ble   pat   line   except   boolean   main   

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:\sqlldr\a.ctl
C:\sqlldr\b.ctl
C:\sqlldr\c.ctl
C:\sqlldr\d.ctl
C:\sqlldr\e.ctl
C:\sqlldr\f.ctl
C:\sqlldr\g.ctl
C:\sqlldr\h.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());
}

}

}

多线程

标签:lld   read   runner   ble   pat   line   except   boolean   main   

原文地址:http://www.cnblogs.com/qq3245792286/p/6219956.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!