public final class IoUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static String |
addEngineModulePathIfRequired(String filePath)
Takes in a file path and returns the file path prefixed with the path of the context-engine module
(if appropriate).
|
static String |
buildUriForStringContent(String content,
String suffix)
Create a temporary file with the string content in it and return the files Uri, e.g.
|
static String |
buildUriForXmlStringContent(String xmlContent)
Create a temporary file with the xml content in it and return the files Uri, e.g.
|
static String |
cleanFilePathSeparators(String path) |
static void |
close(InputStream inputStream)
Null safe closure of input stream.
|
static void |
close(OutputStream outputStream) |
static int |
getLineCount(File file) |
static String[] |
getLines(File file)
Get lines as array from file.
|
static boolean |
resourceExists(String uri) |
static String |
toString(InputStream inputStream) |
static String |
toString(InputStream inputStream,
boolean closeAfter)
Convert input stream to string, returning empty string if input stream is empty.
|
public static String[] getLines(File file) throws IOException
IOExceptionpublic static int getLineCount(File file) throws IOException
IOExceptionpublic static String buildUriForXmlStringContent(String xmlContent) throws IOException
xmlContent - XML contentIOExceptionpublic static String buildUriForStringContent(String content, String suffix) throws IOException
content - contentsuffix - the desired file suffix e.g. ".txt"IOExceptionpublic static String addEngineModulePathIfRequired(String filePath)
filePath - file pathpublic static boolean resourceExists(String uri)
public static String toString(InputStream inputStream, boolean closeAfter)
inputStream - input stream to convert to a stringpublic static String toString(InputStream inputStream)
public static void close(InputStream inputStream)
inputStream - public static void close(OutputStream outputStream)
Copyright (c) 2014-2021 All Rights Reserved by the RWS Group for and on behalf of its affiliates and subsidiaries