JAVA调用shell脚本返回执行结果是否成功?

需求功能:JAVA调用shell导入大量数据,优化数据库(informix),创建索引,整个执行脚本时间预计 2个小时,我是这样做的。】
各位帮忙看看如下代码是否会有什么漏洞或者不足之处,或者有什么更好的办法,谢谢!
Runtime rt = Runtime.getRuntime();
Process p = rt.exec(“shell.sh”);
if(p.waitFor() != 0){
System.out.println("数据导入成功!"+p.waitFor());
}else{
System.out.println("数据导入失败!"+p.waitFor());
}

可根据返回值来判断
[code="java"] StringBuilder result = new StringBuilder();

    InputStream in = proc.getInputStream();
    BufferedReader buf = new BufferedReader(new InputStreamReader(in, "gbk"));
    String line = null;
    while ((line = buf.readLine()) != null){
        result.append(line).append("\r\n");         
    }
    buf.close();
    proc.destroy();

    // 判断返回数据是否正确
    if (result.indexOf("failed") == -1){
        System.out.println("> success");
    } else {
        System.out.println("> failed");
    }[/code]