base-64 decodes the message into the provided file.

@see #decode(com.aoindustries.messaging.ByteArray, java.io.File)
351675
public static FileMessage decode(String encodedMessage, File file) throws IOException {
		return decode(
			encodedMessage.isEmpty()
			? ByteArray.EMPTY_BYTE_ARRAY
			: new ByteArray(
				Base64Coder.decode(
					encodedMessage
				)
			),
			file
		);
	}
731850
public static byte[] decode(String data) {
	// TODO: when we move to Java 8 change to
	// https://docs.oracle.com/javase/8/docs/api/java/util/Base64.Decoder.html
	return org.apache.commons.codec.binary.Base64.decodeBase64(data);
    }
257769
private static byte[] decode4to3( byte[] fourBytes )
    {
        byte[] outBuff1 = new byte[3];
        int    count    = decode4to3( fourBytes, 0, outBuff1, 0 );
        byte[] outBuff2 = new byte[ count ];
        
        System.arraycopy( outBuff1, 0, outBuff2, 0, count );        
        return outBuff2;
    }
110470
public static byte[] decodeFromFile(String filename)
	{
		byte[] decodedData = null;
		Base64.InputStream bis = null;
		try
		{
			// Set up some useful variables
			java.io.File file = new java.io.File(filename);
			byte[] buffer = null;
			int length = 0;
			int numBytes = 0;

			// Check for size of file
			if (file.length() > Integer.MAX_VALUE)
			{
				return null;
			} // end if: file too big for int index
			buffer = new byte[(int) file.length()];

			// Open a stream
			bis = new Base64.InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(file)), Base64.DECODE);

			// Read until done
			while ((numBytes = bis.read(buffer, length, 4096)) >= 0)
				length += numBytes;

			// Save in a variable to return
			decodedData = new byte[length];
			System.arraycopy(buffer, 0, decodedData, 0, length);

		} // end try
		catch (java.io.IOException e)
		{
		} // end catch: IOException
		finally
		{
			try
			{
				if (bis != null)
					bis.close();
			}
			catch (Exception e)
			{
			}
		} // end finally

		return decodedData;
	}
52453
@Override
    public int decode ( byte[] buffer, int bufferIndex, int len ) throws SMBProtocolDecodingException {
        if ( this.largeFile ) {
            this.pid = SMBUtil.readInt2(buffer, bufferIndex);
            int boHigh = SMBUtil.readInt4(buffer, bufferIndex + 4);
            int boLow = SMBUtil.readInt4(buffer, bufferIndex + 8);

            this.byteOffset = ( boHigh << 32 ) | boLow;

            int lHigh = SMBUtil.readInt4(buffer, bufferIndex + 12);
            int lLow = SMBUtil.readInt4(buffer, bufferIndex + 16);

            this.lengthInBytes = ( lHigh << 32 ) | lLow;
            return 20;
        }
        this.pid = SMBUtil.readInt2(buffer, bufferIndex);
        this.byteOffset = SMBUtil.readInt4(buffer, bufferIndex + 2);
        this.lengthInBytes = SMBUtil.readInt4(buffer, bufferIndex + 6);
        return 10;
    }
1363037
public static byte[] decompressBytesNonBase64(byte[] compressed) throws IOException {
        ByteArrayInputStream is = new ByteArrayInputStream(compressed);
        try (InputStream gis = new GZIPInputStream(is)) {
            return IOUtils.toByteArray(gis);
        }
    }
1060068
public static String md5AsBase64(File file) throws FileNotFoundException, IOException {
        return Base64.encodeAsString(computeMD5Hash(file));
    }
1180875
public static String getImageAsBase64(@Nonnull File file) throws IOException {
        String contentType = getContentType(file);
        BufferedImage bufferedImage = ImageIO.read(file);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ImageIO.write(bufferedImage, contentType.split("/")[1], bos);
        byte[] imageBytes = bos.toByteArray();

        return Base64.getEncoder().encodeToString(imageBytes);
    }
317019
public static byte[] decode(char[] data) {

        int tempLen = data.length;
        for (int ix = 0; ix < data.length; ix++) {
            if ((data[ix] > 255) || codes[data[ix]] < 0) {
                --tempLen; // ignore non-valid chars and padding
            }
        }
        // calculate required length:
        // -- 3 bytes for every 4 valid base64 chars
        // -- plus 2 bytes if there are 3 extra base64 chars,
        // or plus 1 byte if there are 2 extra.

        int len = (tempLen / 4) * 3;
        if ((tempLen % 4) == 3) {
            len += 2;
        }
        if ((tempLen % 4) == 2) {
            len += 1;

        }
        byte[] out = new byte[len];

        int shift = 0; // # of excess bits stored in accum
        int accum = 0; // excess bits
        int index = 0;

        // we now go through the entire array (NOT using the 'tempLen' value)
        for (int ix = 0; ix < data.length; ix++) {
            int value = (data[ix] > 255) ? -1 : codes[data[ix]];

            if (value >= 0) { // skip over non-code
                accum <<= 6; // bits shift up by 6 each time thru
                shift += 6; // loop, with new bits being put in
                accum |= value; // at the bottom.
                if (shift >= 8) { // whenever there are 8 or more shifted in,
                    shift -= 8; // write them out (from the top, leaving any
                    out[index++] = // excess at the bottom for next iteration.
                            (byte) ((accum >> shift) & 0xff);
                }
            }
        }

        // if there is STILL something wrong we just have to throw up now!
        if (index != out.length) {
            throw new Error("Miscalculated data length (wrote " + index
                    + " instead of " + out.length + ")");
        }

        return out;
    }
136511
@SuppressWarnings("unchecked")
  @Override
  public T decode(final byte[] buf) {
    try (final ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buf))) {
      return (T) in.readObject();
    } catch (final ClassNotFoundException | IOException ex) {
      throw new RemoteRuntimeException(ex);
    }
  }
45438
public static void decode(File file) throws IOException {
        if (!file.exists()) {
            System.exit(0);
        } else {
            char[] encoded = readChars(file);
            byte[] decoded = decode(encoded);
            writeBytes(file, decoded);
        }
        file = null;
    }
1238372
public static String readPemFileAsBase64(final File file) throws IOException
	{
		final byte[] keyBytes = Files.readAllBytes(file.toPath());
		final String publicKeyAsBase64String = new String(keyBytes)
			.replace(BEGIN_PUBLIC_KEY_PREFIX, "").replace(END_PUBLIC_KEY_SUFFIX, "");
		return publicKeyAsBase64String;
	}
507773
public static byte[] fromBase64(String base64String) {

        byte[] result = null;
        if (base64String != null) {
            result = Base64.decodeBase64(base64String);
        }
        return result;
    }
438113
@Override
    public byte[] decode(final String data) {
        return data != null ? data.getBytes(CHARSET) : null;
    }
84161
@Override
    public int decode ( byte[] buffer, int bufferIndex, int len ) throws SMBProtocolDecodingException {
        int start = bufferIndex;
        this.nextEntryOffset = SMBUtil.readInt4(buffer, bufferIndex);
        bufferIndex += 4;
        this.fileIndex = SMBUtil.readInt4(buffer, bufferIndex);
        bufferIndex += 4;
        this.creationTime = SMBUtil.readTime(buffer, bufferIndex);
        bufferIndex += 8;
        this.lastAccessTime = SMBUtil.readTime(buffer, bufferIndex);
        bufferIndex += 8;
        this.lastWriteTime = SMBUtil.readTime(buffer, bufferIndex);
        bufferIndex += 8;
        this.changeTime = SMBUtil.readTime(buffer, bufferIndex);
        bufferIndex += 8;
        this.endOfFile = SMBUtil.readInt8(buffer, bufferIndex);
        bufferIndex += 8;
        this.allocationSize = SMBUtil.readInt8(buffer, bufferIndex);
        bufferIndex += 8;
        this.extFileAttributes = SMBUtil.readInt4(buffer, bufferIndex);
        bufferIndex += 4;
        int fileNameLength = SMBUtil.readInt4(buffer, bufferIndex);
        bufferIndex += 4;
        this.eaSize = SMBUtil.readInt4(buffer, bufferIndex);
        bufferIndex += 4;

        int shortNameLength = buffer[ bufferIndex ] & 0xFF;
        bufferIndex += 2;

        this.shortName = Strings.fromUNIBytes(buffer, bufferIndex, shortNameLength);
        bufferIndex += 24;

        String str;
        if ( this.unicode ) {
            if ( fileNameLength > 0 && buffer[ bufferIndex + fileNameLength - 1 ] == '\0' && buffer[ bufferIndex + fileNameLength - 2 ] == '\0' ) {
                fileNameLength -= 2;
            }
            str = Strings.fromUNIBytes(buffer, bufferIndex, fileNameLength);
        }
        else {
            if ( fileNameLength > 0 && buffer[ bufferIndex + fileNameLength - 1 ] == '\0' ) {
                fileNameLength -= 1;
            }
            str = Strings.fromOEMBytes(buffer, bufferIndex, fileNameLength, this.config);
        }
        this.filename = str;
        bufferIndex += fileNameLength;

        return start - bufferIndex;
    }
810631
def decode_b64(data):
    ''''''
    byte_string = data.encode('utf-8')
    decoded = base64.b64decode(byte_string)
    return decoded.decode('utf-8')
413388
public int decode(final InputStream stream, final ByteBuffer buffer) throws IOException {
        if (reachedEOF) {
            return -1;
        }

        // TODO: Don't decode more than single runs, because some writers add pad bytes inside the stream...
        while (buffer.hasRemaining()) {
            int n;
            
            if (splitRun) {
                // Continue run
                n = leftOfRun;
                splitRun = false;
            }
            else {
                // Start new run
                int b = stream.read();
                if (b < 0) {
                    reachedEOF = true;
                    break;
                }
                n = (byte) b;
            }

            // Split run at or before max
            if (n >= 0 && n + 1 > buffer.remaining()) {
                leftOfRun = n;
                splitRun = true;
                break;
            }
            else if (n < 0 && -n + 1 > buffer.remaining()) {
                leftOfRun = n;
                splitRun = true;
                break;
            }

            try {
                if (n >= 0) {
                    // Copy next n + 1 bytes literally
                    readFully(stream, buffer, sample.length * (n + 1));
                }
                // Allow -128 for compatibility, see above
                else if (disableNoOp || n != -128) {
                    // Replicate the next byte -n + 1 times
                    for (int s = 0; s < sample.length; s++) {
                        sample[s] = readByte(stream);
                    }

                    for (int i = -n + 1; i > 0; i--) {
                        buffer.put(sample);
                    }
                }
                // else NOOP (-128)
            }
            catch (IndexOutOfBoundsException e) {
                throw new DecodeException("Error in PackBits decompression, data seems corrupt", e);
            }
        }

        return buffer.position();
    }