public class WpIOUtils extends Object
Constructor and Description |
---|
WpIOUtils() |
Modifier and Type | Method and Description |
---|---|
static Serializable |
bytesToObject(byte[] input)
Deserialize an array of bytes into an object.
|
static File |
createTempDirectory(String name) |
static File |
createTempDirectory(String name,
boolean deleteOnExit)
Creates a new temporary directory
|
static long |
getLastModifiedfromDir(File dir)
Return the most recent tstamp among files in a diretory.
|
static String |
getRelativePath(File base,
File path)
Gets the path relative to a specified directory.
|
static void |
mkdirsQuietly(File dir) |
static byte[] |
objectToBytes(Serializable o)
Serialize an object into bytes.
|
static BufferedReader |
openBufferedReader(File path)
Open a possibly compressed file and return a buffered reader for it.
|
static BufferedWriter |
openBZ2Writer(File path) |
static InputStream |
openInputStream(File path)
Opens a possibly compressed input stream.
|
static Reader |
openReader(File path)
Open a possibly compressed file and return a reader for it.
|
static BufferedReader |
openResource(String path)
Opens a resource in the classpath as a buffered reader.
|
static BufferedWriter |
openWriter(File path)
Opens a buffered writer that uses UTF-8 encoding.
|
static BufferedWriter |
openWriter(String path) |
static BufferedWriter |
openWriterForAppend(File path)
Opens a buffered writer that uses UTF-8 encoding.
|
static Object |
readObjectFromFile(File file) |
static String |
resourceToString(String path)
Reads a resource on the classpath into a string and returns it.
|
static void |
writeObjectToFile(File file,
Object o) |
public static void mkdirsQuietly(File dir)
public static void writeObjectToFile(File file, Object o) throws IOException
IOException
public static Object readObjectFromFile(File file) throws IOException
IOException
public static Serializable bytesToObject(byte[] input) throws IOException, ClassNotFoundException
input
- Serialized stream of bytesIOException
ClassNotFoundException
public static long getLastModifiedfromDir(File dir)
dir
- public static byte[] objectToBytes(Serializable o) throws IOException
o
- Object to be serialized.IOException
public static BufferedReader openBufferedReader(File path) throws IOException
path
- IOException
public static BufferedReader openResource(String path) throws IOException
path
- IOException
public static String resourceToString(String path) throws IOException
path
- IOException
public static Reader openReader(File path) throws IOException
path
- IOException
public static InputStream openInputStream(File path) throws IOException
path
- IOException
public static BufferedWriter openWriter(File path) throws IOException
path
- IOException
public static BufferedWriter openWriterForAppend(File path) throws IOException
path
- IOException
public static BufferedWriter openBZ2Writer(File path) throws IOException
IOException
public static File createTempDirectory(String name, boolean deleteOnExit) throws IOException
name
- Name to be embedded within the tmp dirdeleteOnExit
- If true, try to delete the directory when the JVM exits.IOException
public static File createTempDirectory(String name) throws IOException
IOException
createTempDirectory(String, boolean)
public static String getRelativePath(File base, File path)
base
- path
- public static BufferedWriter openWriter(String path) throws IOException
IOException
Copyright © 2018. All rights reserved.