Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    private static final char BASE64PAD = '=';
    private static final byte[] DECODETABLE = new byte[128];

    public static boolean isValidBase64Encoding(String data) {
        for (int i = 0; i < data.length(); i++) {
            char ch = data.charAt(i);
            if (ch == BASE64PAD || ch < DECODETABLE.length && DECODETABLE[ch] != Byte.MAX_VALUE) {
                // do nothing
            } else if (ch == '\r' || ch == '\n') {
                // do nothing
            } else {
                return false;
            }
        }
        return true;
    }
}