Java InputStream Create toInputStreamFromBase64(String inBase64String)

Here you can find the source of toInputStreamFromBase64(String inBase64String)

Description

to Input Stream From Base

License

Open Source License

Declaration

public static InputStream toInputStreamFromBase64(String inBase64String) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.ByteArrayInputStream;

import java.io.InputStream;

import java.util.Base64;

public class Main {
    public static final byte[] EMPTY_BYTES = new byte[0];

    public static InputStream toInputStreamFromBase64(String inBase64String) {

        if (inBase64String == null) {
            return null;
        }// w w w . j a v  a2 s  .  c  o  m

        return new ByteArrayInputStream(toBytesFromBase64(inBase64String));
    }

    public static byte[] toBytesFromBase64(String inBase64String) {

        if (inBase64String == null) {
            return null;
        }
        if (inBase64String.trim().isEmpty()) {
            return EMPTY_BYTES;
        }

        return Base64.getDecoder().decode(inBase64String);
    }
}

Related

  1. toInputStream(String s, String charSet)
  2. toInputStream(String source)
  3. toInputStream(String text)
  4. toInputStream(String value)
  5. toInputStream(String[] stringArray)