Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    /**
     * Check if a printable string is encoded by Base64 or not
     * 
     * @param str
     * @return
     */
    public static boolean isBase64(String str) {
        Pattern pattern = Pattern.compile("^(?:[A-Za-z0-9+/_-]{4})*(?:[A-Za-z0-9+/_-]{2}==|[A-Za-z0-9+/_-]{3}=)?$");
        Matcher matcher = pattern.matcher(str);
        return matcher.find();
    }
}