@Override public void build(@NotNull Project project, @NotNull Collection<FileObject> fileObjects) { Collection<InputStream> memoryCache = new ArrayList<>(); for (FileObject fileObject : fileObjects) { InputStream inputStream; try { // copy stream inputStream = new ResetOnCloseInputStream(new ByteArrayInputStream( IOUtils.getInputStreamBytes(fileObject.getContent().getInputStream())) ); } catch (FileSystemException ignored) { continue; } catch (IOException ignored) { continue; } memoryCache.add(inputStream); } storage = new ServiceParameterStorage(memoryCache); }
/** * Reads a File into memory. * <p> * * @param file * The File to read. * @return A byte array containing the contents of the File * @see InputStream */ public static byte[] getFileBytes(File file) throws IOException { InputStream is = null; try { is = new FileInputStream(file); return getInputStreamBytes(is); } finally { try { if (is != null) is.close(); } catch (IOException e) { Debug.debug(e); } } }
/** * Reads a File into memory. * <p> * * @param file * The File to read. * @return A byte array containing the contents of the File * @see InputStream */ public static byte[] getFileBytes(File file) throws IOException { InputStream is = null; try { is = new FileInputStream(file); return getInputStreamBytes(is); } finally { try { if (is != null) is.close(); } catch (IOException e) { Debug.debug(e); } } }