java.lang.Object
org.apache.jena.util.FileUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BufferedReaderCreate a buffered reader that uses UTF-8 encodingstatic PrintWriterCreate a print writer that uses UTF-8 encodingstatic ReaderasUTF8(InputStream in) Create a reader that uses UTF-8 encodingstatic WriterasUTF8(OutputStream out) Create a writer that uses UTF-8 encodingstatic Stringstatic StringgetDirname(String filename) Get the directory part of a filenamestatic StringgetFilenameExt(String filename) Get the suffix part of a file name or a URL in file-like format.static FilegetScratchDirectory(String prefix) Answer a File naming a freshly-created directory in the temporary directory.static Stringstatic StringGuess the language/type of model data If the URI ends ".rdf", it is assumed to be RDF/XML If the URI ends ".nt", it is assumed to be N-Triples If the URI ends ".ttl", it is assumed to be Turtle If the URI ends ".owl", it is assumed to be RDF/XMLstatic StringGuess the language/type of model data.static booleanCheck whether 'name' is possibly a file referencestatic booleanCheck whether a name is an absolute URI (has a scheme name)static BufferedReaderopenResourceFile(String filename) Answer a BufferedReader than reads from the named resource file as UTF-8, possibly throwing WrappedIOExceptions.static InputStreamopenResourceFileAsStream(String filename) Open an resource file for reading.static BufferedReaderreaderFromURL(String urlStr) static StringRead a whole stream as UTF-8static StringreadWholeFileAsUTF8(String filename) Read a whole file as UTF-8static FiletempFileName(String prefix, String suffix) create a temporary file that will be deleted on exit, and do something sensible with any IO exceptions - namely, throw them up wrapped in a JenaException.static StringtoFilename(String filenameOrURI) Turn a file: URL or file name into a plain file name
-
Field Details
-
langXML
- See Also:
-
langXMLAbbrev
- See Also:
-
langNTriple
- See Also:
-
langN3
- See Also:
-
langTurtle
- See Also:
-
-
Constructor Details
-
FileUtils
public FileUtils()
-
-
Method Details
-
asUTF8
Create a reader that uses UTF-8 encoding -
asBufferedUTF8
Create a buffered reader that uses UTF-8 encoding -
asUTF8
Create a writer that uses UTF-8 encoding -
asPrintWriterUTF8
Create a print writer that uses UTF-8 encoding -
guessLang
Guess the language/type of model data.- If the URI ends ".rdf", it is assumed to be RDF/XML
- If the URI ends ".nt", it is assumed to be N-Triples
- If the URI ends ".ttl", it is assumed to be Turtle
- If the URI ends ".owl", it is assumed to be RDF/XML
- Parameters:
name- URL to base the guess onotherwise- Default guess- Returns:
- String Guessed syntax - or the default supplied
-
guessLang
Guess the language/type of model data- If the URI ends ".rdf", it is assumed to be RDF/XML
- If the URI ends ".nt", it is assumed to be N-Triples
- If the URI ends ".ttl", it is assumed to be Turtle
- If the URI ends ".owl", it is assumed to be RDF/XML
- Parameters:
urlStr- URL to base the guess on- Returns:
- String Guessed syntax - default is RDF/XML
-
toFilename
Turn a file: URL or file name into a plain file name -
decodeFileName
-
isFile
Check whether 'name' is possibly a file reference- Parameters:
name-- Returns:
- boolean False if clearly not a filename.
-
isURI
Check whether a name is an absolute URI (has a scheme name)- Parameters:
name-- Returns:
- boolean True if there is a scheme name
-
getDirname
Get the directory part of a filename- Parameters:
filename-- Returns:
- Directory name
-
getFilenameExt
Get the suffix part of a file name or a URL in file-like format. -
tempFileName
create a temporary file that will be deleted on exit, and do something sensible with any IO exceptions - namely, throw them up wrapped in a JenaException.- Parameters:
prefix- the prefix for File.createTempFilesuffix- the suffix for File.createTempFile- Returns:
- the temporary File
-
getScratchDirectory
Answer a File naming a freshly-created directory in the temporary directory. This directory should be deleted on exit. TODO handle threading issues, mkdir failure, and better cleanup- Parameters:
prefix- the prefix for the directory name- Returns:
- a File naming the new directory
-
getTempDirectory
-
openResourceFile
Answer a BufferedReader than reads from the named resource file as UTF-8, possibly throwing WrappedIOExceptions. -
openResourceFileAsStream
Open an resource file for reading.- Throws:
FileNotFoundException
-
readerFromURL
-
readWholeFileAsUTF8
Read a whole file as UTF-8- Parameters:
filename-- Returns:
- String
- Throws:
IOException
-
readWholeFileAsUTF8
Read a whole stream as UTF-8- Parameters:
in- InputStream to be read- Returns:
- String
- Throws:
IOException
-