Code example for BufferedInputStream

Methods: availableread

0
	 * @param data Eingabedaten 
	 * @return Base64-kodierte Signatur 
	 */ 
	private String sign(String data) {
		try { 
			BufferedInputStream in = new BufferedInputStream(new FileInputStream(
					"keystore/kunden/staffkey.priv")); 
			byte[] key = new byte[in.available()];
			in.read(key);
 
			Signature dsa = Signature.getInstance("SHA1withDSA", "SUN");
			PKCS8EncodedKeySpec privKeySpec = new PKCS8EncodedKeySpec(key);
			KeyFactory keyFactory = KeyFactory.getInstance("DSA", "SUN");
			PrivateKey privKey = keyFactory.generatePrivate(privKeySpec);
 
			dsa.initSign(privKey);
			dsa.update(data.getBytes("UTF-8"));
 
			return Base64.encode(dsa.sign(), false);
 
Contextual code suggestions in your IDE  Get Codota for Java