Package net.sourceforge.pmd.util
Class IOUtil
- java.lang.Object
-
- net.sourceforge.pmd.util.IOUtil
-
@InternalApi @Deprecated public final class IOUtil extends Object
Deprecated.Is internal API- Author:
- Brian Remedios
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
IOUtil.BomAwareInputStream
Deprecated.Input stream that skips an optional byte order mark at the beginning of the stream.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static IOException
closeAll(Collection<? extends AutoCloseable> closeables)
Deprecated.Close all closeable resources in order.static void
closeQuietly(Closeable closeable)
Deprecated.static void
copy(InputStream from, OutputStream to)
Deprecated.static void
copy(Reader from, Writer to)
Deprecated.static Writer
createWriter()
Deprecated.static Writer
createWriter(String reportFile)
Deprecated.Creates a writer that writes to the given file or to stdout.static Writer
createWriter(Charset charset, String reportFile)
Deprecated.Creates a writer that writes to the given file or to stdout.static void
ensureClosed(List<? extends AutoCloseable> toClose, Exception pendingException)
Deprecated.Ensure that the closeables are closed.static boolean
equalsNormalizedPaths(String path1, String path2)
Deprecated.static InputStream
fromReader(Reader reader)
Deprecated.static OutputStream
fromWriter(Writer writer, String encoding)
Deprecated.static String
getFilenameBase(String name)
Deprecated.static String
getFilenameExtension(String name)
Deprecated.static String
normalizePath(String path)
Deprecated.static String
readFileToString(File file)
Deprecated.static String
readFileToString(File file, Charset charset)
Deprecated.static String
readToString(InputStream stream, Charset charset)
Deprecated.static String
readToString(Reader reader)
Deprecated.static Reader
skipBOM(Reader source)
Deprecated.static long
skipFully(InputStream stream, long n)
Deprecated.static byte[]
toByteArray(InputStream stream)
Deprecated.static void
tryCloseClassLoader(ClassLoader classLoader)
Deprecated.
-
-
-
Method Detail
-
createWriter
public static Writer createWriter()
Deprecated.
-
createWriter
public static Writer createWriter(String reportFile)
Deprecated.Creates a writer that writes to the given file or to stdout. The file is created if it does not exist.Warning: This writer always uses the system default charset.
- Parameters:
reportFile
- the file name (optional)- Returns:
- the writer, never null
-
createWriter
public static Writer createWriter(Charset charset, String reportFile)
Deprecated.Creates a writer that writes to the given file or to stdout. The file is created if it does not exist.Unlike
createWriter(String)
, this method always uses the given charset. Even for writing to stdout. It never falls back to the default charset.- Parameters:
charset
- the charset to be used (required)reportFile
- the file name (optional)- Returns:
-
tryCloseClassLoader
public static void tryCloseClassLoader(ClassLoader classLoader)
Deprecated.
-
closeAll
public static IOException closeAll(Collection<? extends AutoCloseable> closeables)
Deprecated.Close all closeable resources in order. If any exception occurs, it is saved and returned. If more than one exception occurs, the following are accumulated as suppressed exceptions in the first.- Parameters:
closeables
- Resources to close- Returns:
- An exception, or null if no 'close' routine threw
-
ensureClosed
public static void ensureClosed(List<? extends AutoCloseable> toClose, Exception pendingException) throws Exception
Deprecated.Ensure that the closeables are closed. In the end, throws the pending exception if not null, or the exception retuned bycloseAll(Collection)
if not null. If both are non-null, adds one of them to the suppress list of the other, and throws that one.- Throws:
Exception
-
closeQuietly
public static void closeQuietly(Closeable closeable)
Deprecated.
-
toByteArray
public static byte[] toByteArray(InputStream stream) throws IOException
Deprecated.- Throws:
IOException
-
skipFully
public static long skipFully(InputStream stream, long n) throws IOException
Deprecated.- Throws:
IOException
-
equalsNormalizedPaths
public static boolean equalsNormalizedPaths(String path1, String path2)
Deprecated.
-
copy
public static void copy(InputStream from, OutputStream to) throws IOException
Deprecated.- Throws:
IOException
-
copy
public static void copy(Reader from, Writer to) throws IOException
Deprecated.- Throws:
IOException
-
readFileToString
public static String readFileToString(File file) throws IOException
Deprecated.- Throws:
IOException
-
readFileToString
public static String readFileToString(File file, Charset charset) throws IOException
Deprecated.- Throws:
IOException
-
readToString
public static String readToString(Reader reader) throws IOException
Deprecated.- Throws:
IOException
-
readToString
public static String readToString(InputStream stream, Charset charset) throws IOException
Deprecated.- Throws:
IOException
-
fromReader
public static InputStream fromReader(Reader reader) throws IOException
Deprecated.- Throws:
IOException
-
fromWriter
public static OutputStream fromWriter(Writer writer, String encoding) throws UnsupportedCharsetException
Deprecated.- Throws:
UnsupportedCharsetException
-
-