Package org.hotswap.agent.util
Class IOUtils
- java.lang.Object
-
- org.hotswap.agent.util.IOUtils
-
public class IOUtils extends Object
IO utils (similar to apache commons).
-
-
Field Summary
Fields Modifier and Type Field Description static StringURL_PROTOCOL_FILEURL protocol for a file in the file system: "file"static StringURL_PROTOCOL_VFSURL protocol for a JBoss VFS resource: "vfs"
-
Constructor Summary
Constructors Constructor Description IOUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringextractFileNameFromInputSource(InputSource inputSource)Extract file name from input source.static StringextractFileNameFromInputStream(InputStream is)Extract file name from input stream.static StringextractFileNameFromReader(Reader reader)Extract file name from reader.static booleanisDirectoryURL(URL url)Determine whether the given URL points to a directory in the file systemstatic booleanisFileURL(URL url)Determine whether the given URL points to a resource in the file system, that is, has protocol "file" or "vfs".static StringstreamToString(InputStream is)Convert input stream to a string.static byte[]toByteArray(URI uri)Download URI to byte array.static StringurlToClassName(URI uri)Return fully qualified class name of class file on a URI.
-
-
-
Field Detail
-
URL_PROTOCOL_FILE
public static final String URL_PROTOCOL_FILE
URL protocol for a file in the file system: "file"- See Also:
- Constant Field Values
-
URL_PROTOCOL_VFS
public static final String URL_PROTOCOL_VFS
URL protocol for a JBoss VFS resource: "vfs"- See Also:
- Constant Field Values
-
-
Method Detail
-
toByteArray
public static byte[] toByteArray(URI uri)
Download URI to byte array. Wait for the file to exists up to 5 seconds - it may be recreated while IDE recompilation, automatic retry will avoid false errors.- Parameters:
uri- uri to process- Returns:
- byte array
- Throws:
IllegalArgumentException- for download problems
-
streamToString
public static String streamToString(InputStream is)
Convert input stream to a string.- Parameters:
is- stream- Returns:
- string (at least empty string for empty stream)
-
isFileURL
public static boolean isFileURL(URL url)
Determine whether the given URL points to a resource in the file system, that is, has protocol "file" or "vfs".- Parameters:
url- the URL to check- Returns:
- whether the URL has been identified as a file system URL
-
isDirectoryURL
public static boolean isDirectoryURL(URL url)
Determine whether the given URL points to a directory in the file system- Parameters:
url- the URL to check- Returns:
- whether the URL has been identified as a file system URL
-
urlToClassName
public static String urlToClassName(URI uri) throws IOException
Return fully qualified class name of class file on a URI.- Parameters:
uri- uri of class file- Returns:
- name
- Throws:
IOException- any exception on class instantiation
-
extractFileNameFromInputStream
public static String extractFileNameFromInputStream(InputStream is)
Extract file name from input stream.- Parameters:
is- the is- Returns:
- the string
-
extractFileNameFromReader
public static String extractFileNameFromReader(Reader reader)
Extract file name from reader.- Parameters:
reader- the reader- Returns:
- the string
-
extractFileNameFromInputSource
public static String extractFileNameFromInputSource(InputSource inputSource)
Extract file name from input source.- Parameters:
inputSource- the input source- Returns:
- the string
-
-