Package com.opengamma.strata.collect.io
Class CharSources
- java.lang.Object
-
- com.opengamma.strata.collect.io.CharSources
-
public final class CharSources extends Object
Helper that allowsCharSourceobjects to be created.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringextractFileName(CharSource source)Extracts the file name from a source.static StringCharSourceofContent(byte[] content)Obtains an instance ofCharSourcefrom a text variable, specified as a byte array.static StringCharSourceofContent(byte[] content, Charset charset)Obtains an instance ofCharSourcefrom a text variable, specified as a byte array.static StringCharSourceofContent(String content)Obtains an instance ofCharSourcefrom a text variable, specified as aStringobject.static CharSourceofFile(File file)Obtains an instance ofCharSourcefrom a file object, specified as aFile.static CharSourceofFile(File file, Charset charset)Obtains an instance ofCharSourcefrom a file object, specified as aFile.static CharSourceofFileName(String fileName)Obtains an instance ofCharSourcefrom a file name, specified as a String.static CharSourceofFileName(String fileName, Charset charset)Obtains an instance ofCharSourcefrom a file name, specified as a String.static CharSourceofPath(Path path)Obtains an instance ofCharSourcefrom a file path, specified as aPath.static CharSourceofPath(Path path, Charset charset)Obtains an instance ofCharSourcefrom a file path, specified as aPath.static CharSourceofUrl(URL url)Obtains an instance ofCharSourcefrom a URL, specified as aURLobject.static CharSourceofUrl(URL url, Charset charset)Obtains an instance ofCharSourcefrom an URL, specified as aURLobject.
-
-
-
Method Detail
-
ofFileName
public static CharSource ofFileName(String fileName)
Obtains an instance ofCharSourcefrom a file name, specified as a String.- Parameters:
fileName- the file name, as a String- Returns:
- a new instance of
CharSourcewith UTF-8 for charset.
-
ofFileName
public static CharSource ofFileName(String fileName, Charset charset)
Obtains an instance ofCharSourcefrom a file name, specified as a String. This also takes in a specific character set, as aCharset.- Parameters:
fileName- the file name, as a Stringcharset- the charset to build the new CharSource based on- Returns:
- a new instance of
CharSource
-
ofFile
public static CharSource ofFile(File file)
Obtains an instance ofCharSourcefrom a file object, specified as aFile.- Parameters:
file- the file object- Returns:
- a new instance of
CharSourcewith UTF-8 for charset.
-
ofFile
public static CharSource ofFile(File file, Charset charset)
Obtains an instance ofCharSourcefrom a file object, specified as aFile. This also takes in a specific character set, as aCharset.- Parameters:
file- the file objectcharset- the charset to build the new CharSource based on- Returns:
- a new instance of
CharSource
-
ofPath
public static CharSource ofPath(Path path)
Obtains an instance ofCharSourcefrom a file path, specified as aPath.- Parameters:
path- the path to create aCharSourcefrom- Returns:
- a new instance of
CharSourcewith UTF-8 for charset.
-
ofPath
public static CharSource ofPath(Path path, Charset charset)
Obtains an instance ofCharSourcefrom a file path, specified as aPath. This also takes in a specific character set, as aCharset.- Parameters:
path- the path to create aCharSourcefromcharset- the charset to build the new CharSource based on- Returns:
- a new instance of
CharSource
-
ofUrl
public static CharSource ofUrl(URL url)
Obtains an instance ofCharSourcefrom a URL, specified as aURLobject.- Parameters:
url- the url to create aCharSourcefrom- Returns:
- a new instance of
CharSourcewith UTF-8 for charset.
-
ofUrl
public static CharSource ofUrl(URL url, Charset charset)
Obtains an instance ofCharSourcefrom an URL, specified as aURLobject. This also takes in a specific character set, as aCharset.- Parameters:
url- the url to create aCharSourcefromcharset- the charset to build the new CharSource based on- Returns:
- a new instance of
CharSource.
-
ofContent
public static StringCharSource ofContent(String content)
Obtains an instance ofCharSourcefrom a text variable, specified as aStringobject.- Parameters:
content- the text to create aCharSourcefor- Returns:
- a new instance of
CharSource
-
ofContent
public static StringCharSource ofContent(byte[] content)
Obtains an instance ofCharSourcefrom a text variable, specified as a byte array.- Parameters:
content- the text to create aCharSourcefor- Returns:
- a new instance of
CharSourcewith UTF-8 for charset
-
ofContent
public static StringCharSource ofContent(byte[] content, Charset charset)
Obtains an instance ofCharSourcefrom a text variable, specified as a byte array. This also takes in a specific character set, as aCharset.- Parameters:
content- the text to create aCharSourceforcharset- the charset to build the new CharSource based on- Returns:
- a new instance of
CharSource
-
extractFileName
public static String extractFileName(CharSource source)
Extracts the file name from a source.- Parameters:
source- the source to extract the file name from- Returns:
- the file name
-
-