For IntelliJ IDEA,
Android Studio or Eclipse



if (arg.startsWith("/")) { FileInputStream stream = new FileInputStream(arg); Protos.PaymentRequest request = Protos.PaymentRequest.parseFrom(stream); stream.close(); session = new PaymentSession(request);
@Override public PaymentSession call() throws Exception { HttpURLConnection connection = (HttpURLConnection)uri.toURL().openConnection(); connection.setRequestProperty("Accept", PaymentProtocol.MIMETYPE_PAYMENTREQUEST); connection.setUseCaches(false); Protos.PaymentRequest paymentRequest = Protos.PaymentRequest.parseFrom(connection.getInputStream()); return new PaymentSession(paymentRequest, verifyPki, trustStoreLoader); } });
@Override public PaymentSession call() throws Exception { HttpURLConnection connection = (HttpURLConnection)uri.toURL().openConnection(); connection.setRequestProperty("Accept", "application/bitcoin-paymentrequest"); connection.setUseCaches(false); Protos.PaymentRequest paymentRequest = Protos.PaymentRequest.parseFrom(connection.getInputStream()); return new PaymentSession(paymentRequest, verifyPki, trustStorePath); } });
@Override public boolean isValidDecryption(InputStream inputStream) throws IOException { try{ Protos.PaymentRequest.parseFrom(inputStream); return true; } catch(InvalidProtocolBufferException ex){ return false; } } }
Optional<Protos.PaymentRequest> paymentRequest = Optional.of(Protos.PaymentRequest.parseFrom(serialisedBytes)); paymentRequestData.setPaymentRequest(paymentRequest);
log.debug("Treating as file based resource"); byte[] paymentRequestBytes = Resources.toByteArray(paymentRequestUri.toURL()); paymentRequest = Protos.PaymentRequest.parseFrom(paymentRequestBytes); paymentSession = new PaymentSession(paymentRequest, checkPKI, trustStoreLoader); log.debug("Treating as classpath based resource"); InputStream inputStream = PaymentProtocolService.class.getResourceAsStream(paymentRequestUri.toString()); paymentRequest = Protos.PaymentRequest.parseFrom(inputStream); paymentSession = new PaymentSession(paymentRequest, checkPKI, trustStoreLoader);
@Override public PaymentSession call() throws Exception { HttpURLConnection connection = (HttpURLConnection)uri.toURL().openConnection(); connection.setRequestProperty("Accept", PaymentProtocol.MIMETYPE_PAYMENTREQUEST); connection.setUseCaches(false); Protos.PaymentRequest paymentRequest = Protos.PaymentRequest.parseFrom(connection.getInputStream()); return new PaymentSession(paymentRequest, verifyPki, trustStoreLoader); } });
@Override public PaymentSession call() throws Exception { HttpURLConnection connection = (HttpURLConnection)uri.toURL().openConnection(); connection.setRequestProperty("Accept", PaymentProtocol.MIMETYPE_PAYMENTREQUEST); connection.setUseCaches(false); Protos.PaymentRequest paymentRequest = Protos.PaymentRequest.parseFrom(connection.getInputStream()); return new PaymentSession(paymentRequest, verifyPki, trustStoreLoader); } });
if (arg.startsWith("/")) { FileInputStream stream = new FileInputStream(arg); Protos.PaymentRequest request = Protos.PaymentRequest.parseFrom(stream); stream.close(); session = new PaymentSession(request);