Package panda.utilities
Class IOUtils
java.lang.Object
panda.utilities.IOUtils
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidClose resource quietly usingclose(java.io.Closeable, java.util.function.Consumer)static voidclose(@Nullable Closeable closeable, @Nullable Consumer<IOException> exceptionConsumer) Null-safe close operationstatic panda.std.Result<String,IOException> convertStreamToString(InputStream inputStream) static panda.std.Result<String,IOException> convertStreamToString(InputStream inputStream, Charset encoding) ConvertInputStreamtoStringstatic InputStreamstatic panda.std.Result<String,IOException> fetchContent(String url) Fetch content of the given websitestatic panda.std.Result<InputStream,IOException> Fetch content of the given website
-
Field Details
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE- See Also:
-
-
Method Details
-
fetchContent
Fetch content of the given website- Parameters:
url- the website to fetch- Returns:
- content of requested page or thrown exception
-
fetchContentAsStream
Fetch content of the given website- Parameters:
url- the website to fetch- Returns:
- content of requested page or thrown exception
-
convertStringToStream
- Parameters:
str- the string to convert- Returns:
- the result input stream
-
convertStreamToString
- Parameters:
inputStream- the input stream to convert- Returns:
- converted string or thrown exception
-
convertStreamToString
public static panda.std.Result<String,IOException> convertStreamToString(InputStream inputStream, Charset encoding) ConvertInputStreamtoString- Parameters:
inputStream- the input stream to convertencoding- the encoding to use- Returns:
- converted string or thrown exception
-
close
Close resource quietly usingclose(java.io.Closeable, java.util.function.Consumer)- Parameters:
closeable- nullable resource to close
-
close
public static void close(@Nullable @Nullable Closeable closeable, @Nullable @Nullable Consumer<IOException> exceptionConsumer) Null-safe close operation- Parameters:
closeable- nullable resource to closeexceptionConsumer- nullable exception consumer
-