Android Open Source - Feeder I O Utils






From Project

Back to project page Feeder.

License

The source code is released under:

GNU General Public License

If you think the Android project Feeder 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

/*
 * $Id: $/*  w ww .  j a v  a 2s . c o  m*/
 *
 * Copyright (C) 2012 Stoyan Rachev (stoyanr@gmail.com)
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2, or (at your option) any
 * later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 */

package com.stoyanr.feeder.util;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

import android.util.Log;

public class IOUtils {
    private static final String TAG = "IOUtils";

    private IOUtils() {
    }

    public static byte[] getByteArray(URL url) {
        byte[] result = null;
        InputStream in = null;
        try {
            in = url.openStream();
            result = IOUtils.getByteArray(in);
        } catch (IOException e) {
            Log.d(TAG, Log.getStackTraceString(e));
        } finally {
            try {
                if (in != null)
                    in.close();
            } catch (IOException e) {
            }
        }
        return result;
    }

    public static byte[] getByteArray(InputStream is) {
        byte[] result = null;
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        int nRead;
        byte[] data = new byte[16384];
        try {
            while ((nRead = is.read(data, 0, data.length)) != -1) {
                buffer.write(data, 0, nRead);
            }
            buffer.flush();
            result = buffer.toByteArray();
        } catch (IOException e) {
            Log.d(TAG, Log.getStackTraceString(e));
        } finally {
            try {
                buffer.close();
            } catch (IOException e) {
            }
        }
        return result;
    }

}




Java Source Code List

com.stoyanr.feeder.activity.AddChannelActivity.java
com.stoyanr.feeder.activity.ChannelsActivity.java
com.stoyanr.feeder.activity.ChannelsAdapter.java
com.stoyanr.feeder.activity.ItemsActivity.java
com.stoyanr.feeder.activity.ItemsAdapter.java
com.stoyanr.feeder.activity.SettingsActivity.java
com.stoyanr.feeder.activity.ViewItemActivity.java
com.stoyanr.feeder.annotations.DefaultSortOrder.java
com.stoyanr.feeder.annotations.MimeType.java
com.stoyanr.feeder.annotations.UriPaths.java
com.stoyanr.feeder.content.AbstractContentProvider.java
com.stoyanr.feeder.content.ContentManager.java
com.stoyanr.feeder.content.DatabaseHelper.java
com.stoyanr.feeder.content.MainContentProvider.java
com.stoyanr.feeder.download.DownloadManager.java
com.stoyanr.feeder.model.Channel.java
com.stoyanr.feeder.model.Data.java
com.stoyanr.feeder.model.Item.java
com.stoyanr.feeder.service.MainService.java
com.stoyanr.feeder.sync.Synchronizer.java
com.stoyanr.feeder.util.BitmapCache.java
com.stoyanr.feeder.util.DateUtils.java
com.stoyanr.feeder.util.DialogUtils.java
com.stoyanr.feeder.util.IOUtils.java
com.stoyanr.feeder.util.KeyUtils.java
com.stoyanr.feeder.util.MenuUtils.java
com.stoyanr.feeder.util.ResourceUtils.java
com.stoyanr.feeder.util.UrlUtils.java
com.stoyanr.feeder.view.ChannelHeader.java
com.stoyanr.feeder.view.ChannelView.java
com.stoyanr.feeder.view.ItemView.java