Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.ByteArrayOutputStream;

public class Main {
    private static byte[] decodes = new byte[128];

    public static byte[] decodeB62(char[] data) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream(data.length);
        try {
            int pos = 0, val = 0;
            for (int i = 0; i < data.length; i++) {
                char c = data[i];
                if (c == 'i') {
                    c = data[++i];
                    c = /**/c == 'a' ? 'i' :
                    /**/c == 'b' ? '+' :
                    /**/c == 'c' ? '/' : data[--i];
                }
                val = (val << 6) | decodes[c];
                pos += 6;
                while (pos > 7) {
                    baos.write(val >> (pos -= 8));
                    val &= ((1 << pos) - 1);
                }
            }
        } catch (Exception e) {
        }
        return baos.toByteArray();
    }
}