/*
* ---------
* |.##> <##.| Open Smart Card Development Platform (www.openscdp.org)
* |# #|
* |# #| Copyright (c) 1999-2006 CardContact Software & System Consulting
* |'##> <##'| Andreas Schwier, 32429 Minden, Germany (www.cardcontact.de)
* ---------
*
* This file is part of OpenSCDP.
*
* OpenSCDP is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* OpenSCDP is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenSCDP; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//
// Function to load a binary file using Java native classes
//
function loadBinaryFile(filename) {
// Open stream
var f = new java.io.FileInputStream(filename);
// Determine file size
var flen = f.available();
// Allocate native byte array
var bs = java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, flen);
// Read into byte array
var len = f.read(bs);
// Allocate JavaScript ByteBuffer from native/wrapped byte array
var bb = new ByteBuffer(bs);
// Convert to JavaScript ByteString
var data = bb.toByteString();
return data;
}
© Copyright 2003 - 2013 CardContact Software & System Consulting, Minden, Germany
