I have inlined temporary FileOutputStream
that I am not able to explicitly close.
Is that a problem?
File raw = new File(uri.getPath());
Bitmap myBitmap = BitmapFactory.decodeFile(uri.getPath());
File compressedPicture = MEUtils.createTemporaryFile(getPackageName());
// see here
myBitmap.compress(Bitmap.CompressFormat.JPEG,
mObjectiveDefinitionForTakingPictureResult.getQuality(),
new FileOutputStream(compressedPicture));
JpegImageMetadata jpegMetadata = (JpegImageMetadata) Sanselan.getMetadata(raw);
TiffImageMetadata exif = jpegMetadata.getExif();
TiffOutputSet outputSet = exif.getOutputSet();
outputSet.setGPSInDegrees(app.locationListener.getLongitude(),
app.locationListener.getLatitude());
File compressedPictureWithMetadata = MEUtils.createTemporaryFile(getPackageName());
// see here
OutputStream compressedPictureWithMetadataOutputStream = new BufferedOutputStream(new FileOutputStream(compressedPictureWithMetadata));
new ExifRewriter().updateExifMetadataLossless(compressedPicture,
compressedPictureWithMetadataOutputStream,
outputSet);
EDIT
It seems that BufferedOutputStream
can conveniently wrap a FileOutputStream
, directly by inline it in the constructor: http://developer.android.com/reference/java/io/BufferedOutputStream.html
using
block. but I don't know enough about Java. does it have something similar? that would automatically close the connection when it is finished using it. \$\endgroup\$