Package org.javacord.core.util
Class FileContainer
- java.lang.Object
-
- org.javacord.core.util.FileContainer
-
public class FileContainer extends Object
A helper class which contains a file which can be in different formats.
-
-
Constructor Summary
Constructors Constructor Description FileContainer(byte[] file, String type)
Creates a new file container with an url.FileContainer(BufferedImage file, String type)
Creates a new file container with a buffered image.FileContainer(File file)
Creates a new file container with a file.FileContainer(InputStream file, String type)
Creates a new file container with an input stream.FileContainer(URL file)
Creates a new file container with an url.FileContainer(Icon file)
Creates a new file container with an icon.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletableFuture<BufferedImage>
asBufferedImage(DiscordApi api)
Gets the file asBufferedImage
.CompletableFuture<byte[]>
asByteArray(DiscordApi api)
Gets the byte array for the file.CompletableFuture<InputStream>
asInputStream(DiscordApi api)
Gets the input stream for the file.String
getFileType()
Gets the type ("png", "txt", ...) of the file.String
getFileTypeOrName()
Gets the type ("png", "txt", ...) or name ("image.png", "readme.txt", ...) of the file.void
setFileTypeOrName(String type)
Sets the type ("png", "txt", ...) or name ("image.png", "readme.txt", ...) of the file.
-
-
-
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.
-
asBufferedImage
public CompletableFuture<BufferedImage> asBufferedImage(DiscordApi api)
Gets the file asBufferedImage
.- Parameters:
api
- The discord api instance.- Returns:
- The file as BufferedImage.
-
-