public static void writeLines(File f, String... lines) throws IOException { try (OutputStream fos = newBufferedOutputStream(f)) { writeLines(fos, lines); } }
public static void writeLines(File f, String... lines) throws IOException { try (OutputStream fos = newBufferedOutputStream(f)) { writeLines(fos, lines); } }
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); } }