/** * Reads traces from a text file, then creates a Cloudlet for each line read. * * @param inputStream a {@link InputStream} to read the file * @param processParsedLineFunction a {@link Function} that receives each parsed line as an array * and performs an operation over it, returning true if the operation was executed * @return <code>true</code> if successful, <code>false</code> otherwise. * @throws IOException if the there was any error reading the file */ protected void readTextFile(final InputStream inputStream, final Function<String[], Boolean> processParsedLineFunction) throws IOException { readFile(inputStream, processParsedLineFunction); }
/** * Reads traces from a gzip file, then creates a Cloudlet for each line read. * * @param inputStream a {@link InputStream} to read the file * @param processParsedLineFunction a {@link Function} that receives each parsed line as an array * and performs an operation over it, returning true if the operation was executed * @return <code>true</code> if successful; <code>false</code> otherwise. * @throws IOException if the there was any error reading the file */ protected void readGZIPFile(final InputStream inputStream, final Function<String[], Boolean> processParsedLineFunction) throws IOException { readFile(new GZIPInputStream(inputStream), processParsedLineFunction); }
/** * Reads a set of trace files inside a Zip file, then creates a Cloudlet for each line read. * * @param inputStream a {@link InputStream} to read the file * @param processParsedLineFunction a {@link Function} that receives each parsed line as an array * and performs an operation over it, returning true if the operation was executed * @return <code>true</code> if reading a file is successful; * <code>false</code> otherwise. * @throws IOException if the there was any error reading the file */ protected boolean readZipFile(final InputStream inputStream, final Function<String[], Boolean> processParsedLineFunction) throws IOException { try (ZipInputStream zipInputStream = new ZipInputStream(requireNonNull(inputStream))) { while (zipInputStream.getNextEntry() != null) { readFile(zipInputStream, processParsedLineFunction); } return true; } }