de.theappguys.winzigsql
Class ResourceUtils

java.lang.Object
  extended by de.theappguys.winzigsql.ResourceUtils

public class ResourceUtils
extends Object

Util methods to read raw assets and resources


Field Summary
static int BYTE_BUFFER_SIZE
           
static int CHAR_BUFFER_SIZE
           
static Charset UTF_8
           
 
Method Summary
static void copy(InputStream in, OutputStream out)
           
static void copy(Reader in, Writer out)
           
static String readAssetAsString(android.content.Context ctx, String name)
          Attempts to read the asset with the given name as a utf-8 string.
static String readRawResourceAsString(android.content.Context ctx, int id)
          Attempts to read the resource with the given id as a utf-8 string.
static String readString(Reader in)
          Reads the contents from the given reader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UTF_8

public static final Charset UTF_8

CHAR_BUFFER_SIZE

public static final int CHAR_BUFFER_SIZE
See Also:
Constant Field Values

BYTE_BUFFER_SIZE

public static final int BYTE_BUFFER_SIZE
See Also:
Constant Field Values
Method Detail

readRawResourceAsString

public static String readRawResourceAsString(android.content.Context ctx,
                                             int id)
                                      throws IOException
Attempts to read the resource with the given id as a utf-8 string.

Throws:
IOException - reading the resource failed (most likely the resource does not exist or cannot be read as a raw resource)

readAssetAsString

public static String readAssetAsString(android.content.Context ctx,
                                       String name)
                                throws IOException
Attempts to read the asset with the given name as a utf-8 string.

Throws:
IOException - reading the asset failed (most likely the given name was wrong)

readString

public static String readString(Reader in)
                         throws IOException
Reads the contents from the given reader. DOES NOT CLOSE THE STREAM!

Parameters:
in - reader to read from, not null
Returns:
the content from the reader
Throws:
IOException - reading failed

copy

public static void copy(Reader in,
                        Writer out)
                 throws IOException
Throws:
IOException

copy

public static void copy(InputStream in,
                        OutputStream out)
                 throws IOException
Throws:
IOException


Copyright © 2013. All Rights Reserved.