Code example for FileInputStream

Methods: closeread

0
	public static byte[] readBytedata(String aFilename) {
		byte[] imgBuffer = null;
		FileInputStream fileInputStream = null;
		try { 
        	File file = new File(aFilename);
        	fileInputStream = new FileInputStream(file);
        	int byteSize = (int)file.length();
        	imgBuffer = new byte[byteSize];
            if (fileInputStream.read(imgBuffer) == -1 ) {
            	Log.e("Memo", "Failed to read image");
            } 
            fileInputStream.close();
		} catch (FileNotFoundException e) {
        	e.printStackTrace();            
        } catch (IOException e2) {
        	e2.printStackTrace();            
        } finally { 
        	if(fileInputStream != null) {
	        	try{ 
	        		fileInputStream.close();
	        	} catch (IOException e) {
	            	e.printStackTrace();            
	            }  
        	} 
        } 
Stop searching for code, let great code find you!  Add Codota to your java IDE