/** * Creates dss document that retains the data in memory * * @param inputStream * input stream representing the document */ public InMemoryDocument(final InputStream inputStream) { this(DSSUtils.toByteArray(inputStream), null, null); }
/** * Creates dss document that retains the data in memory * * @param inputStream * input stream representing the document * @param name * the file name if the data originates from a file */ public InMemoryDocument(final InputStream inputStream, final String name) { this(DSSUtils.toByteArray(inputStream), name); }
/** * Creates dss document that retains the data in memory * * @param inputStream * input stream representing the document * @param name * the file name if the data originates from a file * @param mimeType * the mime type of the file if the data originates from a file */ public InMemoryDocument(final InputStream inputStream, final String name, final MimeType mimeType) { this(DSSUtils.toByteArray(inputStream), name, mimeType); }
protected byte[] getContent(final HttpEntity responseEntity) throws IOException { try (InputStream content = responseEntity.getContent()) { return DSSUtils.toByteArray(content); } }
/** * This method returns an {@code InputStream} which does not need to be closed, based on * {@code ByteArrayInputStream}. * * @param file * {@code File} to read * @return {@code InputStream} based on {@code ByteArrayInputStream} */ public static InputStream toByteArrayInputStream(final File file) { return new ByteArrayInputStream(toByteArray(file)); }
private byte[] getLocalFileContent(final String urlString) { byte[] returnedBytes = null; // TODO usage ?? final String resourcePath = resourceLoader.getAbsoluteResourceFolder(urlString.trim()); if (resourcePath != null) { final File fileResource = new File(resourcePath); returnedBytes = DSSUtils.toByteArray(fileResource); } return returnedBytes; }
/** * This method retrieves data using FTP protocol . * * @param urlString * @return */ protected byte[] ftpGet(final String urlString) { final URL url = getURL(urlString); try (InputStream inputStream = url.openStream()) { return DSSUtils.toByteArray(inputStream); } catch (IOException e) { LOG.warn("Unable to retrieve URL {} content : {}", urlString, e.getMessage()); } return null; }
/** * Allows to load the file for a given file name from the cache folder. * * @return the content of the file or {@code null} if the file does not exist */ public byte[] loadFileFromCache(final String urlString) { final String fileName = ResourceLoader.getNormalizedFileName(urlString); final File file = getCacheFile(fileName); if (file.exists()) { final byte[] bytes = DSSUtils.toByteArray(file); return bytes; } return null; }
/** * Get the contents of an {@code DSSDocument} as a {@code byte[]}. * * @param document * the document to read * @return the content as byte array */ public static byte[] toByteArray(final DSSDocument document) { try (InputStream is = document.openStream()) { return toByteArray(is); } catch (IOException e) { throw new DSSException(e); } }
/** * FROM: Apache * Reads the contents of a file into a byte array. * The file is always closed. * * @param file * the file to read, must not be {@code null} * @return the file contents, never {@code null} */ public static byte[] toByteArray(final File file) { try (InputStream is = openInputStream(file)) { return toByteArray(is); } catch (Exception e) { throw new DSSException(e); } }
final byte[] bytes = DSSUtils.toByteArray(file); return bytes; } else {
final byte[] byteArray = DSSUtils.toByteArray(file); return byteArray; } else {