Class Base64File

java.lang.Object
com.helger.io.codec.base64.Base64File

@Immutable public final class Base64File extends Object
This class contains the File based APIs for Base64
Version:
2.3.7
Author:
Robert Harder, Philip Helger
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    decodeFileToFile(@NonNull String aInFile, @NonNull File aOutFile)
    Reads infile and decodes it to outfile.
    static byte @NonNull []
    decodeFromFile(@NonNull String sFilename)
    Convenience method for reading a base64-encoded file and decoding it.
    static @NonNull com.helger.base.state.ESuccess
    decodeToFile(@NonNull String sDataToDecode, @NonNull File aFile)
    Convenience method for decoding data to a file.
    static void
    encodeFileToFile(@NonNull String infile, @NonNull File aFile)
    Reads infile and encodes it to outfile.
    static @NonNull String
    encodeFromFile(@NonNull String sFilename)
    Convenience method for reading a binary file and base64-encoding it.
    static @NonNull com.helger.base.state.ESuccess
    encodeToFile(byte @NonNull [] aDataToEncode, @NonNull File aFile)
    Convenience method for encoding data to a file.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Base64File

      public Base64File()
  • Method Details

    • encodeToFile

      public static @NonNull com.helger.base.state.ESuccess encodeToFile(byte @NonNull [] aDataToEncode, @NonNull File aFile) throws IOException
      Convenience method for encoding data to a file.

      As of v 2.3, if there is a error, the method will throw an IOException. This is new to v2.3! In earlier versions, it just returned false, but in retrospect that's a pretty poor way to handle it.

      Parameters:
      aDataToEncode - byte array of data to encode in base64 form
      aFile - File for saving encoded data
      Returns:
      ESuccess
      Throws:
      IOException - if there is an error
      NullPointerException - if dataToEncode is null
      Since:
      2.1
    • decodeToFile

      public static @NonNull com.helger.base.state.ESuccess decodeToFile(@NonNull String sDataToDecode, @NonNull File aFile) throws IOException
      Convenience method for decoding data to a file.

      As of v 2.3, if there is a error, the method will throw an IOException. This is new to v2.3! In earlier versions, it just returned false, but in retrospect that's a pretty poor way to handle it.

      Parameters:
      sDataToDecode - Base64-encoded data as a string
      aFile - File for saving decoded data
      Returns:
      ESuccess
      Throws:
      IOException - if there is an error
      Since:
      2.1
    • decodeFromFile

      @ReturnsMutableCopy public static byte @NonNull [] decodeFromFile(@NonNull String sFilename) throws IOException
      Convenience method for reading a base64-encoded file and decoding it.

      As of v 2.3, if there is a error, the method will throw an IOException. This is new to v2.3! In earlier versions, it just returned false, but in retrospect that's a pretty poor way to handle it.

      Parameters:
      sFilename - Filename for reading encoded data
      Returns:
      decoded byte array
      Throws:
      IOException - if there is an error
      Since:
      2.1
    • encodeFromFile

      public static @NonNull String encodeFromFile(@NonNull String sFilename) throws IOException
      Convenience method for reading a binary file and base64-encoding it.

      As of v 2.3, if there is a error, the method will throw an IOException. This is new to v2.3! In earlier versions, it just returned false, but in retrospect that's a pretty poor way to handle it.

      Parameters:
      sFilename - Filename for reading binary data
      Returns:
      base64-encoded string
      Throws:
      IOException - if there is an error
      Since:
      2.1
    • encodeFileToFile

      public static void encodeFileToFile(@NonNull String infile, @NonNull File aFile) throws IOException
      Reads infile and encodes it to outfile.
      Parameters:
      infile - Input file
      aFile - Output file
      Throws:
      IOException - if there is an error
      Since:
      2.2
    • decodeFileToFile

      public static void decodeFileToFile(@NonNull String aInFile, @NonNull File aOutFile) throws IOException
      Reads infile and decodes it to outfile.
      Parameters:
      aInFile - Input file
      aOutFile - Output file
      Throws:
      IOException - if there is an error
      Since:
      2.2