public static InputStream newBuffredInputStream(File f) throws FileNotFoundException { return newBuffredInputStream(new FileInputStream(f)); }
public static InputStream newBuffredInputStream(File f) throws FileNotFoundException { return newBuffredInputStream(new FileInputStream(f)); }
public static List<String> readLines(File f) throws IOException { try (InputStream in = newBuffredInputStream(f)) { return readLines(in); } } }
public static List<String> readLines(File f) throws IOException { try (InputStream in = newBuffredInputStream(f)) { return readLines(in); } } }
public HashAndCompressInputStream(InputStream in) { super(HashUtil.toSHA1InputStream(IOUtil.newBuffredInputStream(in)), new Deflater(Deflater.BEST_COMPRESSION)); }
public HashAndCompressInputStream(InputStream in) { super(HashUtil.toSHA1InputStream(IOUtil.newBuffredInputStream(in)), new Deflater(Deflater.BEST_COMPRESSION)); }
public Email addAttachment(File file, String name){ try (DigestInputStream inHash = HashUtil.toSHA1InputStream(IOUtil.newBuffredInputStream(file))){ String sha1 = HashUtil.bytesToBase16(inHash.getMessageDigest().digest()); return addAttachments(new FileSystemAttachmentRef(file.getName(), sha1, file.getAbsolutePath(), file.length(), name)); } catch (Exception e) { throw new SingularFormException("Erro lendo origem de dados", e); } }
public FileInputStreamAndHash get(File file) throws FileNotFoundException { DigestInputStream din = HashUtil.toSHA1InputStream(IOUtil.newBuffredInputStream(file)); String hash = HashUtil.bytesToBase16(din.getMessageDigest().digest()); return new FileInputStreamAndHash(din, hash); }
private FileSystemAttachmentRef addAttachment(InputStream origin, long originLength, String name, String hashSha1) { String id = UUID.randomUUID().toString(); File temp = findFileFromId(id); try (FileOutputStream f1 = new FileOutputStream(temp); OutputStream fos = IOUtil.newBufferedOutputStream(f1); DigestInputStream inHash = HashUtil.toSHA1InputStream(IOUtil.newBuffredInputStream(origin)); OutputStream infoFOS = IOUtil.newBufferedOutputStream(infoFileFromId(id))) { IOUtils.copy(inHash, fos); String sha1 = HashUtil.bytesToBase16(inHash.getMessageDigest().digest()); IOUtil.writeLines(infoFOS, sha1, String.valueOf(originLength), name); return newRef(id, sha1, temp.getAbsolutePath(), originLength, name); } catch (Exception e) { throw new SingularFormException("Erro adicionando anexo", e); } }
private FileSystemAttachmentRef addAttachment(InputStream origin, long originLength, String name) { String id = UUID.randomUUID().toString(); File temp = findFileFromId(id); try (OutputStream fos = IOUtil.newBufferedOutputStream(temp); DigestInputStream inHash = HashUtil.toSHA1InputStream(IOUtil.newBuffredInputStream(origin)); OutputStream infoFOS = IOUtil.newBufferedOutputStream(infoFileFromId(id))) { IOUtils.copy(inHash, fos); String sha1 = HashUtil.bytesToBase16(inHash.getMessageDigest().digest()); IOUtil.writeLines(infoFOS, sha1, String.valueOf(originLength), name); return newRef(id, sha1, temp.getAbsolutePath(), originLength, name); } catch (Exception e) { throw SingularException.rethrow(e); } }