Android Open Source - Android-Lib-Pen I O Utils






From Project

Back to project page Android-Lib-Pen.

License

The source code is released under:

Apache License

If you think the Android project Android-Lib-Pen listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package android.lib.pen.demo;
//from   w  ww .  j av a2s .  c o  m
import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.util.Log;

final class IOUtils {
    private IOUtils() {
    }

    /**
     * Saves the specified bitmap to a JPG file.
     */
    public static boolean write(final String path, final Bitmap bitmap) {
        OutputStream outputStream = null;

        try {
            outputStream = new BufferedOutputStream(new FileOutputStream(path));

            bitmap.compress(CompressFormat.JPEG, Constants.THUMBNAIL_QUALITY, outputStream);

            return true;
        } catch (final FileNotFoundException e) {
            Log.e(IOUtils.class.getClass().getName(), e.getMessage(), e);
        } finally {
            if (outputStream != null) {
                try {
                    outputStream.close();
                } catch (final IOException e) {
                    Log.w(IOUtils.class.getClass().getName(), e.getMessage(), e);
                }
            }

            bitmap.recycle();
        }

        return false;
    }
}




Java Source Code List

android.lib.pen.PenButton.java
android.lib.pen.PenService.java
android.lib.pen.demo.Constants.java
android.lib.pen.demo.DragDropUtils.java
android.lib.pen.demo.DrawingActivity.java
android.lib.pen.demo.DrawingService.java
android.lib.pen.demo.GalleryAdapter.java
android.lib.pen.demo.IOUtils.java
android.lib.pen.demo.MainActivity.java
android.lib.pen.demo.MultiDragListener.java
android.lib.pen.demo.OnPageUpdatedListener.java
android.lib.pen.demo.OnReplayCompletedListener.java