Class FileContainer



  • public class FileContainer
    extends Object
    A helper class which contains a file which can be in different formats.
    • Constructor Detail

      • FileContainer

        public FileContainer​(BufferedImage file,
                             String type)
        Creates a new file container with a buffered image.
        Parameters:
        file - The file as a buffered image.
        type - The type ("png", "txt", ...) or name ("image.png", "readme.txt", ...) of the file.
      • FileContainer

        public FileContainer​(File file)
        Creates a new file container with a file.
        Parameters:
        file - The file as a file.
      • FileContainer

        public FileContainer​(Icon file)
        Creates a new file container with an icon.
        Parameters:
        file - The file a an icon.
      • FileContainer

        public FileContainer​(URL file)
        Creates a new file container with an url.
        Parameters:
        file - The file as an url.
      • FileContainer

        public FileContainer​(byte[] file,
                             String type)
        Creates a new file container with an url.
        Parameters:
        file - The file as a byte array.
        type - The type ("png", "txt", ...) or name ("image.png", "readme.txt", ...) of the file.
      • FileContainer

        public FileContainer​(InputStream file,
                             String type)
        Creates a new file container with an input stream.
        Parameters:
        file - The file as an input stream.
        type - The type ("png", "txt", ...) or name ("image.png", "readme.txt", ...) of the file.
    • Method Detail

      • setFileTypeOrName

        public void setFileTypeOrName​(String type)
        Sets the type ("png", "txt", ...) or name ("image.png", "readme.txt", ...) of the file.
        Parameters:
        type - The type or name of the file.
      • getFileType

        public String getFileType​()
        Gets the type ("png", "txt", ...) of the file.
        Returns:
        The type of the file.
      • getFileTypeOrName

        public String getFileTypeOrName​()
        Gets the type ("png", "txt", ...) or name ("image.png", "readme.txt", ...) of the file.
        Returns:
        The type or name of the file.
      • asByteArray

        public CompletableFuture<byte[]> asByteArray​(DiscordApi api)
        Gets the byte array for the file.
        Parameters:
        api - The discord api instance.
        Returns:
        The byte array stream for the file.
      • asInputStream

        public CompletableFuture<InputStream> asInputStream​(DiscordApi api)
        Gets the input stream for the file.
        Parameters:
        api - The discord api instance.
        Returns:
        The input stream for the file.