// Path: SMSdroid/src/main/java/org/apache/commons/io/IOUtils.java
// public class IOUtils {
// 	// NOTE: This class is focussed on InputStream, OutputStream, Reader and
// 	// Writer. Each method should take at least one of these as a parameter,
// 	// or return one of them.
// 
// 	/**
// 	 * The Unix directory separator character.
// 	 */
// 	public static final char DIR_SEPARATOR_UNIX = '/';
// 	/**
// 	 * The Windows directory separator character.
// 	 */
// 	public static final char DIR_SEPARATOR_WINDOWS = '\\';
// 	/**
// 	 * The system directory separator character.
// 	 */
// 	public static final char DIR_SEPARATOR = File.separatorChar;
// 	/**
// 	 * The Unix line separator string.
// 	 */
// 	public static final String LINE_SEPARATOR_UNIX = "\n";
// 	/**
// 	 * The Windows line separator string.
// 	 */
// 	public static final String LINE_SEPARATOR_WINDOWS = "\r\n";
// 	/**
// 	 * The system line separator string.
// 	 */
// 	public static final String LINE_SEPARATOR;
// 	static {
// 		// avoid security issues
// 		StringWriter buf = new StringWriter(4);
// 		PrintWriter out = new PrintWriter(buf);
// 		out.println();
// 		LINE_SEPARATOR = buf.toString();
// 	}
// 
// 	/**
// 	 * The default buffer size to use.
// 	 */
// 	private static final int DEFAULT_BUFFER_SIZE = 1024 * 4;
// 
// 	/**
// 	 * Instances should NOT be constructed in standard programming.
// 	 */
// 	public IOUtils() {
// 		super();
// 	}
// 
// 	// copy from InputStream
// 	// -----------------------------------------------------------------------
// 	/**
// 	 * Copy bytes from an <code>InputStream</code> to an
// 	 * <code>OutputStream</code>.
// 	 * <p>
// 	 * This method buffers the input internally, so there is no need to use a
// 	 * <code>BufferedInputStream</code>.
// 	 * <p>
// 	 * Large streams (over 2GB) will return a bytes copied value of
// 	 * <code>-1</code> after the copy has completed since the correct number of
// 	 * bytes cannot be returned as an int. For large streams use the
// 	 * <code>copyLarge(InputStream, OutputStream)</code> method.
// 	 * 
// 	 * @param input
// 	 *            the <code>InputStream</code> to read from
// 	 * @param output
// 	 *            the <code>OutputStream</code> to write to
// 	 * @return the number of bytes copied
// 	 * @throws NullPointerException
// 	 *             if the input or output is null
// 	 * @throws IOException
// 	 *             if an I/O error occurs
// 	 * @throws ArithmeticException
// 	 *             if the byte count is too large
// 	 * @since Commons IO 1.1
// 	 */
// 	public static int copy(final InputStream input, final OutputStream output)
// 			throws IOException {
// 		long count = copyLarge(input, output);
// 		if (count > Integer.MAX_VALUE) {
// 			return -1;
// 		}
// 		return (int) count;
// 	}
// 
// 	/**
// 	 * Copy bytes from a large (over 2GB) <code>InputStream</code> to an
// 	 * <code>OutputStream</code>.
// 	 * <p>
// 	 * This method buffers the input internally, so there is no need to use a
// 	 * <code>BufferedInputStream</code>.
// 	 * 
// 	 * @param input
// 	 *            the <code>InputStream</code> to read from
// 	 * @param output
// 	 *            the <code>OutputStream</code> to write to
// 	 * @return the number of bytes copied
// 	 * @throws NullPointerException
// 	 *             if the input or output is null
// 	 * @throws IOException
// 	 *             if an I/O error occurs
// 	 * @since Commons IO 1.3
// 	 */
// 	public static long copyLarge(final InputStream input,
// 			final OutputStream output) throws IOException {
// 		byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
// 		long count = 0;
// 		int n;
// 		while (-1 != (n = input.read(buffer))) {
// 			output.write(buffer, 0, n);
// 			count += n;
// 		}
// 		return count;
// 	}
// }


import org.apache.commons.io.IOUtils;
import android.Manifest;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Environment;
import android.provider.CallLog.Calls;
import android.view.View;
import android.view.View.OnLongClickListener;
import android.widget.Toast;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.LinkedHashMap;
import de.ub0r.android.logg0r.Log;
                        }
                    } else if (ct.startsWith("audio/")) {
                        switch (ct) {
                            case "audio/3gpp":
                                fn += "3gpp";
                                break;
                            case "audio/mpeg":
                                fn += "mp3";
                                break;
                            case "audio/mid":
                                fn += "mid";
                                break;
                            default:
                                fn += "wav";
                                break;
                        }
                    } else if (ct.startsWith("video/")) {
                        if (ct.equals("video/3gpp")) {
                            fn += "3gpp";
                        } else {
                            fn += "avi";
                        }
                    } else {
                        fn += "ukn";
                    }
                    final File file = Message.this.createUniqueFile(
                            Environment.getExternalStorageDirectory(), fn);
                    //noinspection ConstantConditions
                    InputStream in = context.getContentResolver().openInputStream(ci.getData());
                    OutputStream out = new FileOutputStream(file);
// Path: SMSdroid/src/main/java/org/apache/commons/io/IOUtils.java
// public class IOUtils {
// 	// NOTE: This class is focussed on InputStream, OutputStream, Reader and
// 	// Writer. Each method should take at least one of these as a parameter,
// 	// or return one of them.
// 
// 	/**
// 	 * The Unix directory separator character.
// 	 */
// 	public static final char DIR_SEPARATOR_UNIX = '/';
// 	/**
// 	 * The Windows directory separator character.
// 	 */
// 	public static final char DIR_SEPARATOR_WINDOWS = '\\';
// 	/**
// 	 * The system directory separator character.
// 	 */
// 	public static final char DIR_SEPARATOR = File.separatorChar;
// 	/**
// 	 * The Unix line separator string.
// 	 */
// 	public static final String LINE_SEPARATOR_UNIX = "\n";
// 	/**
// 	 * The Windows line separator string.
// 	 */
// 	public static final String LINE_SEPARATOR_WINDOWS = "\r\n";
// 	/**
// 	 * The system line separator string.
// 	 */
// 	public static final String LINE_SEPARATOR;
// 	static {
// 		// avoid security issues
// 		StringWriter buf = new StringWriter(4);
// 		PrintWriter out = new PrintWriter(buf);
// 		out.println();
// 		LINE_SEPARATOR = buf.toString();
// 	}
// 
// 	/**
// 	 * The default buffer size to use.
// 	 */
// 	private static final int DEFAULT_BUFFER_SIZE = 1024 * 4;
// 
// 	/**
// 	 * Instances should NOT be constructed in standard programming.
// 	 */
// 	public IOUtils() {
// 		super();
// 	}
// 
// 	// copy from InputStream
// 	// -----------------------------------------------------------------------
// 	/**
// 	 * Copy bytes from an <code>InputStream</code> to an
// 	 * <code>OutputStream</code>.
// 	 * <p>
// 	 * This method buffers the input internally, so there is no need to use a
// 	 * <code>BufferedInputStream</code>.
// 	 * <p>
// 	 * Large streams (over 2GB) will return a bytes copied value of
// 	 * <code>-1</code> after the copy has completed since the correct number of
// 	 * bytes cannot be returned as an int. For large streams use the
// 	 * <code>copyLarge(InputStream, OutputStream)</code> method.
// 	 * 
// 	 * @param input
// 	 *            the <code>InputStream</code> to read from
// 	 * @param output
// 	 *            the <code>OutputStream</code> to write to
// 	 * @return the number of bytes copied
// 	 * @throws NullPointerException
// 	 *             if the input or output is null
// 	 * @throws IOException
// 	 *             if an I/O error occurs
// 	 * @throws ArithmeticException
// 	 *             if the byte count is too large
// 	 * @since Commons IO 1.1
// 	 */
// 	public static int copy(final InputStream input, final OutputStream output)
// 			throws IOException {
// 		long count = copyLarge(input, output);
// 		if (count > Integer.MAX_VALUE) {
// 			return -1;
// 		}
// 		return (int) count;
// 	}
// 
// 	/**
// 	 * Copy bytes from a large (over 2GB) <code>InputStream</code> to an
// 	 * <code>OutputStream</code>.
// 	 * <p>
// 	 * This method buffers the input internally, so there is no need to use a
// 	 * <code>BufferedInputStream</code>.
// 	 * 
// 	 * @param input
// 	 *            the <code>InputStream</code> to read from
// 	 * @param output
// 	 *            the <code>OutputStream</code> to write to
// 	 * @return the number of bytes copied
// 	 * @throws NullPointerException
// 	 *             if the input or output is null
// 	 * @throws IOException
// 	 *             if an I/O error occurs
// 	 * @since Commons IO 1.3
// 	 */
// 	public static long copyLarge(final InputStream input,
// 			final OutputStream output) throws IOException {
// 		byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
// 		long count = 0;
// 		int n;
// 		while (-1 != (n = input.read(buffer))) {
// 			output.write(buffer, 0, n);
// 			count += n;
// 		}
// 		return count;
// 	}
// }


// Path: SMSdroid/src/main/java/de/ub0r/android/smsdroid/Message.java
import org.apache.commons.io.IOUtils;
import android.Manifest;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Environment;
import android.provider.CallLog.Calls;
import android.view.View;
import android.view.View.OnLongClickListener;
import android.widget.Toast;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.LinkedHashMap;
import de.ub0r.android.logg0r.Log;

                        }
                    } else if (ct.startsWith("audio/")) {
                        switch (ct) {
                            case "audio/3gpp":
                                fn += "3gpp";
                                break;
                            case "audio/mpeg":
                                fn += "mp3";
                                break;
                            case "audio/mid":
                                fn += "mid";
                                break;
                            default:
                                fn += "wav";
                                break;
                        }
                    } else if (ct.startsWith("video/")) {
                        if (ct.equals("video/3gpp")) {
                            fn += "3gpp";
                        } else {
                            fn += "avi";
                        }
                    } else {
                        fn += "ukn";
                    }
                    final File file = Message.this.createUniqueFile(
                            Environment.getExternalStorageDirectory(), fn);
                    //noinspection ConstantConditions
                    InputStream in = context.getContentResolver().openInputStream(ci.getData());
                    OutputStream out = new FileOutputStream(file);
                    IOUtils.copy(in, out);