@Override public InputStream getInputStream() { if (small != null) { return new ByteArrayInputStream(small); } else if (fileName != null) { FileStorage fileStorage = handler.openFile(fileName, "r", true); boolean alwaysClose = SysProperties.LOB_CLOSE_BETWEEN_READS; return new BufferedInputStream(new FileStorageInputStream(fileStorage, handler, false, alwaysClose), Constants.IO_BUFFER_SIZE); } long byteCount = (type == Value.BLOB) ? precision : -1; try { return handler.getLobStorage().getInputStream(this, hmac, byteCount); } catch (IOException e) { throw DbException.convertIOException(e, toString()); } }
/** * Open the input stream. */ void openInput() { String file = getFileName(); if (file == null) { return; } if (isEncrypted()) { initStore(); in = new FileStorageInputStream(fileStorage, this, compressionAlgorithm != null, false); } else { InputStream inStream; try { inStream = FileUtils.newInputStream(file); } catch (IOException e) { throw DbException.convertIOException(e, file); } in = new BufferedInputStream(inStream, Constants.IO_BUFFER_SIZE); in = CompressTool.wrapInputStream(in, compressionAlgorithm, SCRIPT_SQL); if (in == null) { throw DbException.get(ErrorCode.FILE_NOT_FOUND_1, SCRIPT_SQL + " in " + file); } } }