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 allowsCharSource
objects to be created.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
extractFileName(CharSource source)
Extracts the file name from a source.static StringCharSource
ofContent(byte[] content)
Obtains an instance ofCharSource
from a text variable, specified as a byte array.static StringCharSource
ofContent(byte[] content, Charset charset)
Obtains an instance ofCharSource
from a text variable, specified as a byte array.static StringCharSource
ofContent(String content)
Obtains an instance ofCharSource
from a text variable, specified as aString
object.static CharSource
ofFile(File file)
Obtains an instance ofCharSource
from a file object, specified as aFile
.static CharSource
ofFile(File file, Charset charset)
Obtains an instance ofCharSource
from a file object, specified as aFile
.static CharSource
ofFileName(String fileName)
Obtains an instance ofCharSource
from a file name, specified as a String.static CharSource
ofFileName(String fileName, Charset charset)
Obtains an instance ofCharSource
from a file name, specified as a String.static CharSource
ofPath(Path path)
Obtains an instance ofCharSource
from a file path, specified as aPath
.static CharSource
ofPath(Path path, Charset charset)
Obtains an instance ofCharSource
from a file path, specified as aPath
.static CharSource
ofUrl(URL url)
Obtains an instance ofCharSource
from a URL, specified as aURL
object.static CharSource
ofUrl(URL url, Charset charset)
Obtains an instance ofCharSource
from an URL, specified as aURL
object.
-
-
-
Method Detail
-
ofFileName
public static CharSource ofFileName(String fileName)
Obtains an instance ofCharSource
from a file name, specified as a String.- Parameters:
fileName
- the file name, as a String- Returns:
- a new instance of
CharSource
with UTF-8 for charset.
-
ofFileName
public static CharSource ofFileName(String fileName, Charset charset)
Obtains an instance ofCharSource
from 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 ofCharSource
from a file object, specified as aFile
.- Parameters:
file
- the file object- Returns:
- a new instance of
CharSource
with UTF-8 for charset.
-
ofFile
public static CharSource ofFile(File file, Charset charset)
Obtains an instance ofCharSource
from 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 ofCharSource
from a file path, specified as aPath
.- Parameters:
path
- the path to create aCharSource
from- Returns:
- a new instance of
CharSource
with UTF-8 for charset.
-
ofPath
public static CharSource ofPath(Path path, Charset charset)
Obtains an instance ofCharSource
from a file path, specified as aPath
. This also takes in a specific character set, as aCharset
.- Parameters:
path
- the path to create aCharSource
fromcharset
- 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 ofCharSource
from a URL, specified as aURL
object.- Parameters:
url
- the url to create aCharSource
from- Returns:
- a new instance of
CharSource
with UTF-8 for charset.
-
ofUrl
public static CharSource ofUrl(URL url, Charset charset)
Obtains an instance ofCharSource
from an URL, specified as aURL
object. This also takes in a specific character set, as aCharset
.- Parameters:
url
- the url to create aCharSource
fromcharset
- 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 ofCharSource
from a text variable, specified as aString
object.- Parameters:
content
- the text to create aCharSource
for- Returns:
- a new instance of
CharSource
-
ofContent
public static StringCharSource ofContent(byte[] content)
Obtains an instance ofCharSource
from a text variable, specified as a byte array.- Parameters:
content
- the text to create aCharSource
for- Returns:
- a new instance of
CharSource
with UTF-8 for charset
-
ofContent
public static StringCharSource ofContent(byte[] content, Charset charset)
Obtains an instance ofCharSource
from a text variable, specified as a byte array. This also takes in a specific character set, as aCharset
.- Parameters:
content
- the text to create aCharSource
forcharset
- 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
-
-