Package org.terrier.utility.io

Examples of org.terrier.utility.io.FileSystem


  /** What is the parent path to the specified path? */
  public static String getParent(String path)
  {
    path = transform(path);
        final FileSystem fs = getFileSystem(path);
        if (fs == null)
            return null;
        if ((fs.capabilities() & FSCapability.STAT) == 0)
            return null;
        try{
            return fs.getParent(path);
        } catch (IOException ioe) {
            return null;
       
  }
View Full Code Here


  private static final String[] EMPTY_STRING_ARRAY = new String[0];
  /** List the contents of a directory */
  public static String[] list(String path)
  {
    path = transform(path);
        final FileSystem fs = getFileSystem(path);
        if (fs == null)
            return EMPTY_STRING_ARRAY;
        if ((fs.capabilities() & FSCapability.LS_DIR) == 0)
            return EMPTY_STRING_ARRAY;
        try{
            return fs.list(path);
        } catch (IOException ioe) {
            return EMPTY_STRING_ARRAY;
        }

  }
View Full Code Here

      return fileSystems.get(DEFAULT_SCHEME);
    //identify scheme component of filename
    final int colonPos = filename.indexOf(":");
    final String scheme = filename.substring(0, colonPos).toLowerCase();
    //obtain the filesystem representing the scheme
    FileSystem rtr = fileSystems.get(scheme);
    //if (rtr ==  null)
    //{ 
      //throw new RuntimeException("FileSystem for "+filename +"(scheme '"+scheme+"') not found. Configured schemes are: "
      //    + ArrayUtils.join(fileSystems.keySet().toArray(new String[0]), ", "));
    //}
View Full Code Here

    * @return name Name of the file system, or null if no filesystem found
    */
  public static String getFileSystemName(String path)
  {
    path = transform(path);
    final FileSystem fs = getFileSystem(path);
    if (fs == null)
      return null;
    return fs.name();
  }
View Full Code Here

   * @throws IOException
   */
  protected static InputStream openFile(String filename) throws IOException
  {
    filename = transform(filename);
    final FileSystem fs = getFileSystem(filename);
    if (fs == null)
      throw new FileNotFoundException("No file system for "+filename);
    if ((fs.capabilities() & FSCapability.READ) == 0)
      throw new IOException("File system not supporting reads for "+ filename);
       
    InputStream rtr = fs.openFileStream(filename);
    for(Pattern regex : inputStreamMap.keySet())
    {
      if (regex.matcher(filename).matches())
      {
        Class<? extends InputStream> filterClass = inputStreamMap.get(regex);
View Full Code Here

   * @throws IOException
   */
  protected static OutputStream writeFile(String filename) throws IOException
  {
    filename = transform(filename);
    final FileSystem fs = getFileSystem(filename);
    if (fs == null)
      throw new FileNotFoundException("No file system for "+filename);
    if ((fs.capabilities() & FSCapability.WRITE) == 0)
      throw new IOException("File system not supporting writes for "+ filename);
    OutputStream rtr = fs.writeFileStream(filename);
    for(Pattern regex : outputStreamMap.keySet())
    {
      if (regex.matcher(filename).matches())
      {
        Class<? extends OutputStream> filterClass = outputStreamMap.get(regex);
View Full Code Here

  /** Returns a RandomAccessFile implementation accessing the specificed file */
  public static RandomDataInput openFileRandom(String filename) throws IOException
  {
    filename = transform(filename);
    final FileSystem fs = getFileSystem(filename);
    if (fs == null)
      throw new FileNotFoundException("No file system for "+filename);
    if ((fs.capabilities() & FSCapability.RANDOM_READ) == 0)
      throw new IOException("File system not supporting random reads for "+ filename);
    return fs.openFileRandom(filename);
  }
View Full Code Here

TOP

Related Classes of org.terrier.utility.io.FileSystem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.