/** * 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 in the stream to read * @return the whole content of the stream in a single String. * @throws IOException if an I/O exception occured */ public static byte[] getAllContentFrom(final URL url) throws IOException { final InputStream in = url.openStream(); return Misc.getAllContentFrom(in); }
public static byte[] getClassData(final Class< ? > clazz) throws IOException { if (clazz == null) { throw new IOException("Class is null."); } final String className = clazz.getName(); final String newClassName = className.substring(className.lastIndexOf(".") + 1) + ".class"; InputStream inputStream = clazz.getResourceAsStream(newClassName); return Misc.getAllContentFrom(inputStream); }
/** * 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 { final InputStream in = url.openStream(); try { return Misc.getAllContentFrom(in); } finally { in.close(); } }
/** * 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 { final InputStream in = url.openStream(); try { return Misc.getAllContentFrom(in); } finally { in.close(); } }
/** * 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 occured */ public static byte[] getAllContentFrom(final File file) throws IOException { InputStream in = null; try { in = new FileInputStream(file); return Misc.getAllContentFrom(in); } finally { Misc.close(in); } }
/** * Equivalent to {@link #getAllContentFrom(InputStream) * getAllContentFrom(source.getByteStream(source))}; * * @param file the file to read * @return the whole content of the file in a single String. * @throws IOException If an I/O exception occured */ public static byte[] getAllContentFrom(final InputSource source) throws IOException { InputStream in = null; try { in = source.getByteStream(); return Misc.getAllContentFrom(in); } finally { Misc.close(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 { InputStream in = null; try { in = new FileInputStream(file); return Misc.getAllContentFrom(in); } finally { Misc.close(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 { InputStream in = null; try { in = new FileInputStream(file); return Misc.getAllContentFrom(in); } finally { Misc.close(in); } }
/** * Equivalent to {@link #getAllContentFrom(InputStream) getAllContentFrom(source.getByteStream(source))}; * * @param source * the file to read * @return the whole content of the file in a single String. * @throws IOException * IOException If an I/O exception occurs */ public static byte[] getAllContentFrom(final InputSource source) throws IOException { InputStream in = null; try { in = source.getByteStream(); return Misc.getAllContentFrom(in); } finally { Misc.close(in); } }
/** * Equivalent to {@link #getAllContentFrom(InputStream) getAllContentFrom(source.getByteStream(source))}; * * @param source * the file to read * @return the whole content of the file in a single String. * @throws IOException * IOException If an I/O exception occurs */ public static byte[] getAllContentFrom(final InputSource source) throws IOException { InputStream in = null; try { in = source.getByteStream(); return Misc.getAllContentFrom(in); } finally { Misc.close(in); } }
public static BusinessArchive getBusinessArchive(final File businessArchiveFile, final boolean deserializeProcess) throws IOException, ClassNotFoundException { if (!businessArchiveFile.exists()) { throw new FileNotFoundException("File " + businessArchiveFile + "doesn't exists."); } byte[] fileAsBytes = Misc.getAllContentFrom(businessArchiveFile); Map<String, byte[]> resources = Misc.getResourcesFromZip(fileAsBytes); return getBusinessArchive(resources, deserializeProcess); }
public static BusinessArchive getBusinessArchive(final File businessArchiveFile, final boolean deserializeProcess) throws IOException, ClassNotFoundException { if (!businessArchiveFile.exists()) { throw new FileNotFoundException("File " + businessArchiveFile + "doesn't exists."); } byte[] fileAsBytes = Misc.getAllContentFrom(businessArchiveFile); Map<String, byte[]> resources = Misc.getResourcesFromZip(fileAsBytes); return getBusinessArchive(resources, deserializeProcess); }
public static byte[] getBusinessArchiveContent(final URL xpdlURL, final Class< ? >... classes) throws IOException { Misc.checkArgsNotNull(xpdlURL); return getBusinessArchiveContent(xpdlURL.toString(), Misc.getAllContentFrom(xpdlURL), classes); }
public static byte[] getClassData(final Class< ? > clazz) throws IOException { if (clazz == null) { String message = ExceptionManager.getInstance().getFullMessage("buc_CDT_2"); throw new IOException(message); } final String resource = clazz.getName().replace('.', '/') + ".class"; InputStream inputStream = clazz.getClassLoader().getResourceAsStream(resource); byte[] data = null; try { if (inputStream == null) { throw new IOException("Impossible to get stream from class: " + clazz.getName() + ", className= " + resource); } data = Misc.getAllContentFrom(inputStream); } finally { if (inputStream != null) { inputStream.close(); } } return data; }
public static byte[] getClassData(final Class< ? > clazz) throws IOException { if (clazz == null) { String message = ExceptionManager.getInstance().getFullMessage("buc_CDT_2"); throw new IOException(message); } final String resource = clazz.getName().replace('.', '/') + ".class"; InputStream inputStream = clazz.getClassLoader().getResourceAsStream(resource); byte[] data = null; try { if (inputStream == null) { throw new IOException("Impossible to get stream from class: " + clazz.getName() + ", className= " + resource); } data = Misc.getAllContentFrom(inputStream); } finally { if (inputStream != null) { inputStream.close(); } } return data; }
@Override public byte[] getResource(final ProcessDefinitionUUID definitionUUID, final String resourcePath) throws ProcessNotFoundException { getInternalProcess(definitionUUID); final ClassLoader classLoader = EnvTool.getClassDataLoader().getProcessClassLoader(definitionUUID); final InputStream in = classLoader.getResourceAsStream(resourcePath); byte[] resource = null; if (in != null) { try { resource = Misc.getAllContentFrom(in); in.close(); } catch (final IOException e) { } } return resource; }
@SuppressWarnings("unchecked") private <T> T getData(final Class<T> clazz, final File file) { try { final byte[] value = Misc.getAllContentFrom(file); return (T) Misc.deserialize(value); } catch (final IOException e) { throw new BonitaRuntimeException(e); } catch (final ClassNotFoundException e) { throw new BonitaRuntimeException(e); } }
LOG.severe("File : " + f + " does not exist. Can't add it to the BAR."); } else { resources.put(file, Misc.getAllContentFrom(f));
LOG.severe("File : " + f + " does not exist. Can't add it to the BAR."); } else { resources.put(file, Misc.getAllContentFrom(f));
content = Misc.getAllContentFrom(url); } catch (final IOException e) { String message = ExceptionManager.getInstance().getFullMessage("benv_GEF_1", url);