Java String Decode decode(String s)

Here you can find the source of decode(String s)

Description

decode

License

Apache License

Declaration

public static <T extends Serializable> T decode(String s) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.ByteArrayInputStream;

import java.io.IOException;

import java.io.ObjectInputStream;

import java.io.Serializable;

import java.util.Base64;

public class Main {
    public static <T extends Serializable> T decode(String s) {
        byte[] decode = Base64.getDecoder().decode(s);
        try (ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(decode);
                ObjectInputStream si = new ObjectInputStream(byteArrayInputStream)) {
            return (T) si.readObject();
        } catch (ClassNotFoundException | IOException e) {
            throw new UnsupportedOperationException(e);
        }/*w  w  w . java 2s.  c  o  m*/
    }
}

Related

  1. decode(String s)
  2. decode(String s)
  3. decode(String s)
  4. decode(String s)
  5. decode(String s)
  6. decode(String s)
  7. decode(String s, Class clazz)
  8. decode(String s, String charset1, String charset2)
  9. decode(String s, String enc, boolean plusToSpace)