Package edu.umd.cs.findbugs.io
Class IO
- java.lang.Object
-
- edu.umd.cs.findbugs.io.IO
-
public class IO extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description IO()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidclose(@Nullable java.io.Closeable c)Close given Closeable instance, ignoring any resulting exception.static voidclose(@Nullable java.io.InputStream inputStream)Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removed in or after October 2026.static voidclose(@Nullable java.io.OutputStream outputStream)Close given OutputStream, ignoring any resulting exception.static voidclose(@Nullable java.lang.AutoCloseable c)Close given AutoCloseable instance, ignoring any resulting exception.static longcopy(java.io.InputStream in, java.io.OutputStream out)static longcopy(java.io.InputStream in, java.io.OutputStream out, long maxBytes)static longcopy(java.io.Reader in, java.io.Writer out)static longcopy(java.io.Reader in, java.io.Writer out, long maxChars)(package private) static byte[]copyOf(byte[] original, int newLength)static @NonNull java.net.URLConnectionopenNonCachedConnection(@NonNull java.net.URL u)When URL Connection uses cache, it may keep file handler.static @NonNull java.io.InputStreamopenNonCachedStream(@NonNull java.net.URL u)When URL Connection uses cache, it may keep file handler.static byte[]readAll(java.io.InputStream in)static byte[]readAll(java.io.InputStream in, int size)static java.lang.StringreadAll(java.io.Reader reader)static voidskipFully(java.io.InputStream in, long bytes)Provide a skip fully method.static booleanverifyURL(java.net.URL u)
-
-
-
Method Detail
-
readAll
public static byte[] readAll(@WillClose java.io.InputStream in) throws java.io.IOException- Throws:
java.io.IOException
-
copyOf
static byte[] copyOf(byte[] original, int newLength)
-
readAll
public static byte[] readAll(@WillClose java.io.InputStream in, int size) throws java.io.IOException- Throws:
java.io.IOException
-
readAll
public static java.lang.String readAll(java.io.Reader reader) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static long copy(@WillNotClose java.io.InputStream in, @WillNotClose java.io.OutputStream out) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static long copy(java.io.Reader in, java.io.Writer out) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static long copy(@WillNotClose java.io.InputStream in, @WillNotClose java.io.OutputStream out, long maxBytes) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static long copy(java.io.Reader in, java.io.Writer out, long maxChars) throws java.io.IOException- Throws:
java.io.IOException
-
close
public static void close(@Nullable java.lang.AutoCloseable c)
Close given AutoCloseable instance, ignoring any resulting exception.
-
close
public static void close(@Nullable java.io.Closeable c)
Close given Closeable instance, ignoring any resulting exception.
-
close
@Deprecated(forRemoval=true) public static void close(@Nullable java.io.InputStream inputStream)
Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated and will be removed in or after October 2026. Use try-with resources when creating the stream instead.Close given InputStream, ignoring any resulting exception.- Parameters:
inputStream- the InputStream to close; may be null (in which case nothing happens)
-
close
public static void close(@Nullable java.io.OutputStream outputStream)
Close given OutputStream, ignoring any resulting exception.- Parameters:
outputStream- the OutputStream to close; may be null (in which case nothing happens)
-
skipFully
public static void skipFully(java.io.InputStream in, long bytes) throws java.io.IOExceptionProvide a skip fully method. Either skips the requested number of bytes or throws an IOException;- Parameters:
in- The input stream on which to perform the skipbytes- Number of bytes to skip- Throws:
java.io.EOFException- if we reach EOF and still need to skip more bytesjava.io.IOException- if in.skip throws an IOException
-
verifyURL
public static boolean verifyURL(java.net.URL u)
-
openNonCachedConnection
@CheckReturnValue public static @NonNull java.net.URLConnection openNonCachedConnection(@NonNull java.net.URL u) throws java.io.IOException
When URL Connection uses cache, it may keep file handler. This method open connection without caching to avoid file handler leak.- Returns:
- opened
URLConnectionwhich does not use cache to load data - Throws:
java.io.IOException- See Also:
- related GitHub issue
-
openNonCachedStream
@CheckReturnValue public static @NonNull java.io.InputStream openNonCachedStream(@NonNull java.net.URL u) throws java.io.IOException
When URL Connection uses cache, it may keep file handler. This method open connection without caching to avoid file handler leak.- Returns:
- opened
URLConnectionwhich does not use cache to load data - Throws:
java.io.IOException- See Also:
- related GitHub issue
-
-