if (displayHeader(bos, path, file2 == null)) { bos.close(); bos.writeTo(result);
if (displayHeader(result, path, file2 == null)) {
    public void displayFileDiff(String path, File file1, File file2,            String rev1, String rev2, String mimeType1, String mimeType2, OutputStream result) throws SVNException {        path = getDisplayPath(path);        int i = 0;        for(; i < myAnchorPath1.length() && i < myAnchorPath2.length() &&            myAnchorPath1.charAt(i) == myAnchorPath2.charAt(i); i++) {}        if (i < myAnchorPath1.length() || i < myAnchorPath2.length()) {            if (i == myAnchorPath1.length()) {                i = myAnchorPath1.length() - 1;            }            for(; i > 0 && myAnchorPath1.charAt(i) != '/'; i--) {}        }        String p1 = myAnchorPath1.substring(i) ;        String p2 = myAnchorPath2.substring(i);                if (p1.length() == 0) {            p1 = path;        } else if (p1.charAt(0) == '/') {            p1 = path + "\t(..." + p1 + ")";        } else {            p1 = path + "\t(.../" + p1 + ")";        }        if (p2.length() == 0) {            p2 = path;        } else if (p2.charAt(0) == '/') {            p2 = path + "\t(..." + p2 + ")";        } else {            p2 = path + "\t(.../" + p2 + ")";        }                // if anchor1 is the same as anchor2 just use path.                // if anchor1 differs from anchor2 =>        // condence anchors (get common root and remainings).                rev1 = rev1 == null ? WC_REVISION_LABEL : rev1;        rev2 = rev2 == null ? WC_REVISION_LABEL : rev2;        ByteArrayOutputStream bos = new ByteArrayOutputStream();        try {            if (displayHeader(bos, path, file2 == null)) {                bos.close();                bos.writeTo(result);                return;            }        } catch (IOException e) {            try {                bos.close();                bos.writeTo(result);            } catch (IOException inner) {            }            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e.getLocalizedMessage());            SVNErrorManager.error(err, e);        }        if (!isForcedBinaryDiff() && (SVNProperty.isBinaryMimeType(mimeType1) || SVNProperty.isBinaryMimeType(mimeType2))) {            try {                displayBinary(bos, mimeType1, mimeType2);            } catch (IOException e) {                SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e.getLocalizedMessage());                SVNErrorManager.error(err, e);            } finally {                try {                    bos.close();                    bos.writeTo(result);                } catch (IOException e) {                }            }            return;        }        if (file1 == file2 && file1 == null) {            try {                bos.close();                bos.writeTo(result);            } catch (IOException e) {            }            return;        }        // put header fields.        try {            displayHeaderFields(bos, p1, rev1, p2, rev2);        } catch (IOException e) {            try {                bos.close();                bos.writeTo(result);            } catch (IOException inner) {            }            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e.getLocalizedMessage());            SVNErrorManager.error(err, e);        }	      String header;        try {            bos.close();            header = bos.toString();        } catch (IOException inner) {            header = "";        }        InputStream is1 = null;        InputStream is2 = null;        try {            is1 = file1 == null ? EMPTY_FILE_IS : SVNFileUtil.openFileForReading(file1);            is2 = file2 == null ? EMPTY_FILE_IS : SVNFileUtil.openFileForReading(file2);            QDiffUniGenerator.setup();            Map properties = new HashMap();                        properties.put(QDiffGeneratorFactory.IGNORE_EOL_PROPERTY, Boolean.valueOf(getDiffOptions().isIgnoreEOLStyle()));            if (getDiffOptions().isIgnoreAllWhitespace()) {                properties.put(QDiffGeneratorFactory.IGNORE_SPACE_PROPERTY, QDiffGeneratorFactory.IGNORE_ALL_SPACE);            } else if (getDiffOptions().isIgnoreAmountOfWhitespace()) {                properties.put(QDiffGeneratorFactory.IGNORE_SPACE_PROPERTY, QDiffGeneratorFactory.IGNORE_SPACE_CHANGE);            }            QDiffGenerator generator = new QDiffUniGenerator(properties, header);            Writer writer = new OutputStreamWriter(result, getEncoding());            QDiffManager.generateTextDiff(is1, is2, getEncoding(), writer, generator);            writer.flush();        } catch (IOException e) {            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e.getLocalizedMessage());            SVNErrorManager.error(err, e);        } finally {            SVNFileUtil.closeFile(is1);            SVNFileUtil.closeFile(is2);        }    }