@Override public InputStream newInputStream() throws IOException { return base.newInputStream(); }
/** * Create an input stream to read from the file. * This method is similar to Java 7 * <code>java.nio.file.Path.newInputStream</code>. * * @param fileName the file name * @return the input stream */ public static InputStream newInputStream(String fileName) throws IOException { return FilePath.get(fileName).newInputStream(); }
@Override public InputStream newInputStream() throws IOException { InputStream input = getBase().newInputStream(); for (int i = 1;; i++) { FilePath f = getBase(i); if (f.exists()) { InputStream i2 = f.newInputStream(); input = new SequenceInputStream(input, i2); } else { break; } } return input; }
private static void backupFiles(String path, String toFile) { try (OutputStream zip = FileUtils.newOutputStream(toFile, false); ZipOutputStream out = new ZipOutputStream(zip)) { FilePath p = FilePath.get(path); if (p.isDirectory()) { String pathShortName = path.replace('\\', '/'); pathShortName = pathShortName.substring(pathShortName.lastIndexOf('/') + 1); FilePath dir = FilePath.get(path); for (FilePath map : dir.newDirectoryStream()) { String entryNameBase = pathShortName + "/" + map.getName(); for (FilePath file : map.newDirectoryStream()) { backupFile(out, file.newInputStream(), entryNameBase + "/" + file.getName()); } } } else { backupFile(out, p.newInputStream(), p.getName()); } } catch (IOException e) { throw DbException.convertIOException(e, toFile); } }