String errString = ""; if(readErrorStream){ InputStream is = null; StringBuffer result = null; is = hookProcess.getErrorStream(); result = new StringBuffer(); int r; try{ while (is != null && (r = is.read()) >= 0) { result.append((char) (r & 0xFF)); } }catch(IOException ioe){  }finally{ SVNFileUtil.closeFile(is); } errString = result.toString();
if(errorGobbler.getError() != null){ SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, errorGobbler.getError().getLocalizedMessage()); SVNErrorManager.error(err, errorGobbler.getError());
    private static void runHook(File hook, String hookName, Process hookProcess, String stdInValue, boolean readErrorStream) throws SVNException {        if(hookProcess == null){            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.REPOS_HOOK_FAILURE, "Failed to start ''{0}'' hook", hook);            SVNErrorManager.error(err);        }        if(stdInValue != null){            OutputStream osToStdIn = hookProcess.getOutputStream();            try{                osToStdIn.write(stdInValue.getBytes());            }catch(IOException ioe){                SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.REPOS_HOOK_FAILURE, "Failed to start ''{0}'' hook: {1}", new Object[]{hook, ioe.getLocalizedMessage()});                SVNErrorManager.error(err, ioe);            }finally{                SVNFileUtil.closeFile(osToStdIn);            }        }        int rc = -1;        try{            rc = hookProcess.waitFor();        }catch(InterruptedException ie){            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.REPOS_HOOK_FAILURE, "Failed to start ''{0}'' hook: {1}", new Object[]{hook, ie.getLocalizedMessage()});            SVNErrorManager.error(err, ie);        }        String errString = "";        if(readErrorStream){            InputStream is = null;            StringBuffer result = null;            is = hookProcess.getErrorStream();            result = new StringBuffer();            int r;                        try{                while (is != null && (r = is.read()) >= 0) {                    result.append((char) (r & 0xFF));                }            }catch(IOException ioe){                //            }finally{                SVNFileUtil.closeFile(is);            }            errString = result.toString();        }        if (rc != 0) {            if(!readErrorStream){                SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.REPOS_HOOK_FAILURE, "''{0}'' hook failed; no error output available", hookName);                SVNErrorManager.error(err);            }else{                SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.REPOS_HOOK_FAILURE, "''{0}'' hook failed with error output:\n{1}", new Object[]{hookName, errString});                SVNErrorManager.error(err);            }        }    }