resource leak fix from Coverity Scan

This commit is contained in:
Terence Parr 2013-08-31 13:01:53 -07:00
parent 9c186c8d52
commit d4f2abc5e3
1 changed files with 3 additions and 2 deletions

View File

@ -87,8 +87,8 @@ public class GraphicsSupport {
StreamPrintServiceFactory[] factories =
StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor, mimeType);
System.out.println(Arrays.toString(factories));
FileOutputStream out = new FileOutputStream(fileName);
if (factories.length > 0) {
FileOutputStream out = new FileOutputStream(fileName);
PrintService service = factories[0].getPrintService(out);
SimpleDoc doc = new SimpleDoc(new Printable() {
@Override
@ -115,6 +115,7 @@ public class GraphicsSupport {
DocPrintJob job = service.createPrintJob();
PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
job.print(doc, attributes);
out.close();
}
} else {
// parrt: works with [image/jpeg, image/png, image/x-png, image/vnd.wap.wbmp, image/bmp, image/gif]