/** * Equivalent to {@link #getAllContentFrom(InputStream) getAllContentFrom(new * FileInputStream(file))}; * * @param file the file to read * @return the whole content of the file in a single String. * @throws IOException If an I/O exception occurs */ public static byte[] getAllContentFrom(final File file) throws IOException { try (InputStream in = new FileInputStream(file)) { return getAllContentFrom(in); } }
/** * Return the whole underlying stream content into a single String. * Warning: the whole content of stream will be kept in memory!! Use with * care! * * @param url the URL to read * @return the whole content of the stream in a single String. * @throws IOException if an I/O exception occurs */ public static byte[] getAllContentFrom(final URL url) throws IOException { try (InputStream in = url.openStream()) { return getAllContentFrom(in); } }
/** * Return the whole underlying stream content into a single String. * Warning: the whole content of stream will be kept in memory!! Use with * care! * * @param url the URL to read * @return the whole content of the stream in a single String. * @throws IOException if an I/O exception occurs */ public static byte[] getAllContentFrom(final URL url) throws IOException { try (InputStream in = url.openStream()) { return getAllContentFrom(in); } }
/** * Equivalent to {@link #getAllContentFrom(InputStream) getAllContentFrom(new * FileInputStream(file))}; * * @param file the file to read * @return the whole content of the file in a single String. * @throws IOException If an I/O exception occurs */ public static byte[] getAllContentFrom(final File file) throws IOException { try (InputStream in = new FileInputStream(file)) { return getAllContentFrom(in); } }
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Objects.requireNonNull(file); Objects.requireNonNull(attrs); businessArchive.addResource(barRootFolder.relativize(file).toString().replace(File.separator, "/"), IOUtil.getAllContentFrom(file.toFile())); resourcesCount++; return FileVisitResult.CONTINUE; }
public static byte[] getClassData(final Class<?> clazz) throws IOException { if (clazz == null) { final String message = "Class is null"; throw new IOException(message); } final String resource = clazz.getName().replace('.', '/') + ".class"; byte[] data; try (InputStream inputStream = clazz.getClassLoader().getResourceAsStream(resource)) { if (inputStream == null) { throw new IOException("Impossible to get stream from class: " + clazz.getName() + ", className= " + resource); } data = IOUtil.getAllContentFrom(inputStream); } return data; }
public static byte[] getClassData(final Class<?> clazz) throws IOException { if (clazz == null) { final String message = "Class is null"; throw new IOException(message); } final String resource = clazz.getName().replace('.', '/') + ".class"; byte[] data; try (InputStream inputStream = clazz.getClassLoader().getResourceAsStream(resource)) { if (inputStream == null) { throw new IOException("Impossible to get stream from class: " + clazz.getName() + ", className= " + resource); } data = IOUtil.getAllContentFrom(inputStream); } return data; }
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Objects.requireNonNull(file); Objects.requireNonNull(attrs); businessArchive.addResource(barRootFolder.relativize(file).toString().replace(File.separator, "/"), IOUtil.getAllContentFrom(file.toFile())); resourcesCount++; return FileVisitResult.CONTINUE; }
String fieldName = item.getFieldName(); if (fieldName.startsWith(BINARY_PARAMETER)) { binaryParameters.add(IOUtil.getAllContentFrom(stream)); } else { String read = IOUtil.read(stream);
String fieldName = item.getFieldName(); if (fieldName.startsWith(BINARY_PARAMETER)) { binaryParameters.add(IOUtil.getAllContentFrom(stream)); } else { String read = IOUtil.read(stream);
public static void deployCommand(final APISession apiSession) throws BonitaException { final CommandAPI commandAPI = TenantAPIAccessor.getCommandAPI(apiSession); byte[] commandJar; try { commandJar = IOUtil.getAllContentFrom(APITestUtil.class.getResourceAsStream("/server-command.bak")); } catch (final IOException e) { throw new RetrieveException(e); } commandAPI.addDependency("commands", commandJar); commandAPI.register("waitServerCommand", "waitServerCommand", "org.bonitasoft.engine.test.synchro.WaitServerCommand"); commandAPI.register("addHandlerCommand", "addHandlerCommand", "org.bonitasoft.engine.test.synchro.AddHandlerCommand"); final Map<String, Serializable> parameters = Collections.emptyMap(); commandAPI.execute("addHandlerCommand", parameters); }