• 多线程


    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());
    }

    }

    }

  • 相关阅读:
    select服务器模型
    网络编程-并发服务器基础
    生产者消费者模型
    readv()和write()sendfile()
    snprintf函数的用法
    struct stat结构体的简介
    half-socket
    结构体struct sockaddr_in, struct sockaddr,struct in_addr
    int main(int argc,char* argv[])的作用
    fgets和fputs,fread和fwrite,fscanf,和fprintf用法小结
  • 原文地址:https://www.cnblogs.com/qq3245792286/p/6219956.html
Copyright © 2020-2023  润新知