Code example for MappedByteBuffer

Methods: get

0
	        fin = new FileInputStream(f);
	        ch = fin.getChannel();
	        int size = (int) ch.size();
	        MappedByteBuffer buf = ch.map(MapMode.READ_ONLY, 0, size);
	        bytes = new byte[size];
	        buf.get(bytes);
 
	    } catch (IOException e) {
	        // TODO Auto-generated catch block 
	        e.printStackTrace();
	    } finally { 
	        try { 
	            if (fin != null) {
	                fin.close();
	            } 
	            if (ch != null) {
	                ch.close();
	            } 
	        } catch (IOException e) {
	            // TODO Auto-generated catch block 
	            e.printStackTrace();