Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/FileUtils.java
/**
	 * Reads the entire contents of a binary file from the APK. 
	 * The contents are returned as a byte array. 
	 * 
	 * @author Ian Copland
	 * 
	 * @param The activity
	 * @param The filename.
	 * 
	 * @return The file contents.
	 */
Reads the entire contents of a binary file from the APK.
The contents are returned as a byte array.

@author Ian Copland

@param The activity
@param The filename.

@return The file contents.
Reads the entire contents of a binary file from the APK . The contents are returned as a byte array . @author Ian Copland @param The activity @param The filename . @return The file contents .
public static byte[] readFileAPK(Activity in_activity, String in_filePath)
	{
		final int k_bufferSize = 1024;
		DynamicByteBuffer dynamicByteBuffer = new DynamicByteBuffer(k_bufferSize);
		try
		{
			if (doesFileExistAPK(in_activity, in_filePath) == true)
			{
				InputStream stream = null;
				try
				{
					stream = new BufferedInputStream(in_activity.getAssets().open(in_filePath));
					byte[] buffer = new byte[k_bufferSize];
					int numRead = 0;
					while(numRead != -1)
					{
						numRead = stream.read(buffer, 0, k_bufferSize); 
						if (numRead > 0)
						{
							dynamicByteBuffer.appendBytes(buffer, numRead);
						}
					}
				}
		        catch (Exception e)
		        {
		        	throw e;
		        }
				finally
				{
					if (stream != null)
					{
						stream.close();
					}
				}
			}
		}
		catch (Exception e)
		{
			Logging.logError(ExceptionUtils.ConvertToString(e));
		}
		return dynamicByteBuffer.toByteArray();
	}
public static byte [ ] readFileAPK ( Activity in_activity , String in_filePath ) { final int k_bufferSize = 1024 ; DynamicByteBuffer dynamicByteBuffer = new DynamicByteBuffer ( k_bufferSize ) ; try { if ( doesFileExistAPK ( in_activity , in_filePath ) == true ) { InputStream stream = null ; try { stream = new BufferedInputStream ( in_activity . getAssets ( ) . open ( in_filePath ) ) ; byte [ ] buffer = new byte [ k_bufferSize ] ; int numRead = 0 ; while ( numRead != - 1 ) { numRead = stream . read ( buffer , 0 , k_bufferSize ) ; if ( numRead > 0 ) { dynamicByteBuffer . appendBytes ( buffer , numRead ) ; } } } catch ( Exception e ) { throw e ; } finally { if ( stream != null ) { stream . close ( ) ; } } } } catch ( Exception e ) { Logging . logError ( ExceptionUtils . ConvertToString ( e ) ) ; } return dynamicByteBuffer . toByteArray ( ) ; }
Reads the entire contents of a binary file from the APK.
Reads the entire contents of a binary file from the APK .