public class MockStringContentFactory extends Object
Constructor and Description |
---|
MockStringContentFactory() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
getBytesFromString(String string,
CompressionType compressionType)
Turns a string into a sequence of bytes, possibly compressed.
|
static InputStream |
getFailingInputStream()
Returns an input stream that will throw IOExceptions on common reading
operations.
|
static String |
getStringFromBufferedReader(BufferedReader bufferedReader)
Loads a string from the given buffered reader.
|
static String |
getStringFromInputStream(InputStream inputStream)
Loads a string from the given input stream.
|
static String |
getStringFromUrl(URL url)
Loads a string from the file at the given URL.
|
static InputStream |
newMockInputStream(byte[] contents)
Returns a new InputStream that gives access to the contents as given in
the input bytes.
|
static InputStream |
newMockInputStream(String contents)
Returns a new InputStream that gives access to the contents as given in
the input string, encoded in UTF-8.
|
public static InputStream newMockInputStream(String contents)
contents
- public static InputStream newMockInputStream(byte[] contents)
contents
- public static String getStringFromUrl(URL url) throws IOException
url
- IOException
- if the URL could not be resolved or the file could not be
readpublic static String getStringFromBufferedReader(BufferedReader bufferedReader) throws IOException
bufferedReader
- IOException
- if it was not possible to read from the buffered readerpublic static String getStringFromInputStream(InputStream inputStream) throws IOException
inputStream
- IOException
- if it was not possible to read from the buffered readerpublic static InputStream getFailingInputStream()
public static byte[] getBytesFromString(String string, CompressionType compressionType) throws IOException
string
- compressionType
- IOException
Copyright © 2014–2024 Wikidata Toolkit Developers. Generated from source code published under the Apache License 2.0. For more information, see the Wikidata Toolkit homepage