Skip to content

Commit e2bc3f0

Browse files
fix: adding try-resources for stream
1 parent 0c13132 commit e2bc3f0

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/main/java/br/com/swconsultoria/nfe/Assinar.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,16 @@ private static void loadCertificates(ConfiguracoesNfe config, XMLSignatureFactor
157157

158158
private static String outputXML(Document doc) throws NfeException {
159159

160-
try {
161-
ByteArrayOutputStream os = new ByteArrayOutputStream();
160+
try (ByteArrayOutputStream os = new ByteArrayOutputStream()){
162161
TransformerFactory tf = TransformerFactory.newInstance();
163162
Transformer trans = tf.newTransformer();
164163
trans.transform(new DOMSource(doc), new StreamResult(os));
165164
String xml = os.toString();
166165
xml = xml.replaceAll("\\r\\n", "");
167166
xml = xml.replaceAll(" standalone=\"no\"", "");
168167
return xml;
169-
} catch (TransformerException e) {
170-
throw new NfeException("Erro ao Transformar Documento:" + e.getMessage());
168+
} catch (TransformerException | IOException e) {
169+
throw new NfeException("Erro ao Transformar Documento:" + e.getMessage(),e);
171170
}
172-
173171
}
174-
175172
}

0 commit comments

Comments
 (0)