Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.hp.hpl.jena.util
Class FileUtils

    java.lang.Object
      com.hp.hpl.jena.util.FileUtils

    public class FileUtils

extends java.lang.Object

Field Summary
`static java.lang.String` | `encodingUTF8` Java name for UTF-8 encoding
`static java.lang.String` | `langBDB`
`static java.lang.String` | `langN3`
`static java.lang.String` | `langNTriple`
`static java.lang.String` | `langSQL`
`static java.lang.String` | `langTurtle`
`static java.lang.String` | `langXML`
`static java.lang.String` | `langXMLAbbrev`

Constructor Summary
`FileUtils()`

Method Summary
`static java.io.BufferedReader` | `asBufferedUTF8(java.io.InputStream in)` Create a buffered reader that uses UTF-8 encoding
`static java.io.PrintWriter` | `asPrintWriterUTF8(java.io.OutputStream out)` Create a print writer that uses UTF-8 encoding
`static java.io.Reader` | `asUTF8(java.io.InputStream in)` Create a reader that uses UTF-8 encoding
`static java.io.Writer` | `asUTF8(java.io.OutputStream out)` Create a writer that uses UTF-8 encoding
`static java.lang.String` | `decodeFileName(java.lang.String s)`
`static java.lang.String` | `encodeFileName(java.lang.String s)` Deprecated. Broken: use toURL()
`static java.lang.String` | `getBasename(java.lang.String filename)` Get the basename of a filename
`static java.lang.String` | `getDirname(java.lang.String filename)` Get the directory part of a filename
`static java.lang.String` | `getFilenameExt(java.lang.String filename)` Get the suffix part of a file name or a URL in file-like format.
`static java.lang.String` | `getScheme(java.lang.String uri)`
`static java.io.File` | `getScratchDirectory(java.lang.String prefix)` Answer a File naming a freshly-created directory in the temporary directory.
`static java.lang.String` | `getTempDirectory()`
`static java.lang.String` | `guessLang(java.lang.String urlStr)` Guess the language/type of model data If the URI of the model starts jdbc: it is assumed to be an RDB model If the URI ends .rdf, it is assumed to be RDF/XML If the URI ends .n3, it is assumed to be N3 If the URI ends .nt, it is assumed to be N-Triples If the URI ends .bdb, it is assumed to be BerkeleyDB model
`static java.lang.String` | `guessLang(java.lang.String name, java.lang.String otherwise)` Guess the language/type of model data.
`static boolean` | `isFile(java.lang.String name)` Check whether 'name' is possibly a file reference
`static boolean` | `isURI(java.lang.String name)` Check whether a name is an absolute URI (has a scheme name)
`static java.io.BufferedReader` | `openResourceFile(java.lang.String filename)` Answer a BufferedReader than reads from the named resource file as UTF-8, possibly throwing WrappedIOExceptions.
`static java.io.InputStream` | `openResourceFileAsStream(java.lang.String filename)` Open an resource file for reading.
`static java.io.BufferedReader` | `readerFromURL(java.lang.String urlStr)`
`static java.lang.String` | `readWholeFileAsUTF8(java.io.InputStream in)` Read a whole stream as UTF-8
`static java.lang.String` | `readWholeFileAsUTF8(java.lang.String filename)` Read a whole file as UTF-8
`static java.io.File` | `tempFileName(java.lang.String prefix, java.lang.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 java.lang.String` | `toFilename(java.lang.String filenameOrURI)` Turn a file: URL or file name into a plain file name
`static java.lang.String` | `toURL(java.lang.String filename)` Turn a plain filename into a "file:" URL

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### langXML

    public static final java.lang.String langXML

See Also:
  Constant Field Values

### langXMLAbbrev

    public static final java.lang.String langXMLAbbrev

See Also:
  Constant Field Values

### langNTriple

    public static final java.lang.String langNTriple

See Also:
  Constant Field Values

### langN3

    public static final java.lang.String langN3

See Also:
  Constant Field Values

### langTurtle

    public static final java.lang.String langTurtle

See Also:
  Constant Field Values

### langBDB

    public static final java.lang.String langBDB

See Also:
  Constant Field Values

### langSQL

    public static final java.lang.String langSQL

See Also:
  Constant Field Values

### encodingUTF8

    public static final java.lang.String encodingUTF8

  Java name for UTF-8 encoding

  See Also:
    Constant Field Values

Constructor Detail

### FileUtils

    public FileUtils()

Method Detail

### asUTF8

    public static java.io.Reader asUTF8(java.io.InputStream in)

  Create a reader that uses UTF-8 encoding

### asBufferedUTF8

    public static java.io.BufferedReader asBufferedUTF8(java.io.InputStream in)

  Create a buffered reader that uses UTF-8 encoding

### asUTF8

    public static java.io.Writer asUTF8(java.io.OutputStream out)

  Create a writer that uses UTF-8 encoding

### asPrintWriterUTF8

    public static java.io.PrintWriter asPrintWriterUTF8(java.io.OutputStream out)

  Create a print writer that uses UTF-8 encoding

### guessLang

    public static java.lang.String guessLang(java.lang.String name,
                                             java.lang.String otherwise)

  Guess the language/type of model data. Updated by Chris, hived off the model-suffix part to FileUtils as part of unifying it with similar code in FileGraph.
  - If the URI of the model starts jdbc: it is assumed to be an RDB model
  - If the URI ends ".rdf", it is assumed to be RDF/XML
  - If the URI end .nt, it is assumed to be N-Triples
  - If the URI end .bdb, it is assumed to be BerkeleyDB model [suppressed at present]

  Parameters:
    `name` - URL to base the guess on
    `otherwise` - Default guess
  Returns:
    String Guessed syntax - or the default supplied

### guessLang

    public static java.lang.String guessLang(java.lang.String urlStr)

  Guess the language/type of model data
  - If the URI of the model starts jdbc: it is assumed to be an RDB model
  - If the URI ends .rdf, it is assumed to be RDF/XML
  - If the URI ends .n3, it is assumed to be N3
  - If the URI ends .nt, it is assumed to be N-Triples
  - If the URI ends .bdb, it is assumed to be BerkeleyDB model

  Parameters:
    `urlStr` - URL to base the guess on
  Returns:
    String Guessed syntax - default is RDF/XML

### toFilename

    public static java.lang.String toFilename(java.lang.String filenameOrURI)

  Turn a file: URL or file name into a plain file name

### decodeFileName

    public static java.lang.String decodeFileName(java.lang.String s)

### toURL

    public static java.lang.String toURL(java.lang.String filename)

  Turn a plain filename into a "file:" URL

### encodeFileName

    public static java.lang.String encodeFileName(java.lang.String s)

  Deprecated. Broken: use toURL()

### isFile

    public static boolean isFile(java.lang.String name)

  Check whether 'name' is possibly a file reference

  Parameters:
    `name` -
  Returns:
    boolean False if clearly not a filename.

### isURI

    public static boolean isURI(java.lang.String name)

  Check whether a name is an absolute URI (has a scheme name)

  Parameters:
    `name` -
  Returns:
    boolean True if there is a scheme name

### getScheme

    public static java.lang.String getScheme(java.lang.String uri)

### getDirname

    public static java.lang.String getDirname(java.lang.String filename)

  Get the directory part of a filename

  Parameters:
    `filename` -
  Returns:
    Directory name

### getBasename

    public static java.lang.String getBasename(java.lang.String filename)

  Get the basename of a filename

  Parameters:
    `filename` -
  Returns:
    Base filename.

### getFilenameExt

    public static java.lang.String getFilenameExt(java.lang.String filename)

  Get the suffix part of a file name or a URL in file-like format.

### tempFileName

    public static java.io.File tempFileName(java.lang.String prefix,
                                            java.lang.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.

  Parameters:
    `prefix` - the prefix for File.createTempFile
    `suffix` - the suffix for File.createTempFile
  Returns:
    the temporary File

### getScratchDirectory

    public static java.io.File getScratchDirectory(java.lang.String prefix)

  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

    public static java.lang.String getTempDirectory()

### openResourceFile

    public static java.io.BufferedReader openResourceFile(java.lang.String filename)

  Answer a BufferedReader than reads from the named resource file as UTF-8, possibly throwing WrappedIOExceptions.

### openResourceFileAsStream

    public static java.io.InputStream openResourceFileAsStream(java.lang.String filename)
                                                        throws java.io.FileNotFoundException

  Open an resource file for reading.

  Throws:
    `java.io.FileNotFoundException`

### readerFromURL

    public static java.io.BufferedReader readerFromURL(java.lang.String urlStr)

### readWholeFileAsUTF8

    public static java.lang.String readWholeFileAsUTF8(java.lang.String filename)
                                                throws java.io.IOException

  Read a whole file as UTF-8

  Parameters:
    `filename` -
  Returns:
    String
  Throws:
    `java.io.IOException`

### readWholeFileAsUTF8

    public static java.lang.String readWholeFileAsUTF8(java.io.InputStream in)
                                                throws java.io.IOException

  Read a whole stream as UTF-8

  Parameters:
    `in` - InputStream to be read
  Returns:
    String
  Throws:
    `java.io.IOException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP