always use buffered output streams when writing to a file, faster swf xml export by caching the fields

This commit is contained in:
2015-05-01 01:04:08 +02:00
parent 1429757552
commit fce4534aed
18 changed files with 78 additions and 34 deletions
@@ -19,9 +19,11 @@ package com.jpexs.decompiler.flash.helpers;
import java.awt.Component;
import java.awt.Image;
import java.awt.image.PixelGrabber;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
* Adapted from
@@ -77,7 +79,7 @@ public class BMPFile extends Component {
private int[] bitmap;
//--- File section
private FileOutputStream fo;
private OutputStream fo;
//--- Private constructor
private BMPFile() {
@@ -85,7 +87,7 @@ public class BMPFile extends Component {
public static void saveBitmap(Image image, File file) throws IOException {
BMPFile b = new BMPFile();
try (FileOutputStream fos = new FileOutputStream(file)) {
try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) {
b.fo = fos;
b.save(image, image.getWidth(null), image.getHeight(null));
}
@@ -19,7 +19,7 @@ package com.jpexs.decompiler.flash.helpers;
import com.jpexs.decompiler.flash.helpers.hilight.HighlightData;
import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType;
import com.jpexs.helpers.utf8.Utf8OutputStreamWriter;
import java.io.BufferedWriter;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.Writer;
@@ -43,7 +43,7 @@ public class FileTextWriter extends GraphTextWriter implements AutoCloseable {
public FileTextWriter(CodeFormatting formatting, FileOutputStream fos) {
super(formatting);
this.writer = new BufferedWriter(new Utf8OutputStreamWriter(fos));
this.writer = new Utf8OutputStreamWriter(new BufferedOutputStream(fos));
}
@Override