public class HdfsUtil
extends java.lang.Object
| Constructor and Description | 
|---|
| HdfsUtil() | 
| Modifier and Type | Method and Description | 
|---|---|
| static java.io.File | copyFromHDFStoLocal(java.lang.String hdfsFile, java.lang.String localFile, org.apache.hadoop.conf.Configuration conf)Copies specified HDFS file to Local FileSystem | 
| static void | deleteFile(java.lang.String path, org.apache.hadoop.conf.Configuration conf)Deletes file from HDFS | 
| static org.apache.hadoop.conf.Configuration | getConf(org.apache.hadoop.fs.FileSystem fs)Return the configuration for this fileSystem | 
| static org.apache.hadoop.fs.FileStatus | getFile(java.lang.String path, org.apache.hadoop.conf.Configuration conf)Gets the specified file from HDFS | 
| static org.apache.hadoop.fs.FileStatus[] | getFiles(org.apache.hadoop.fs.Path hdfsPath, org.apache.hadoop.conf.Configuration conf)Gets the list of files contained in the specified folder | 
| static org.apache.hadoop.fs.Path | getHomeHDFSDirectory(org.apache.hadoop.conf.Configuration conf)Return the current user's home directory in this filesystem | 
| static org.apache.hadoop.fs.FileStatus[] | listFolderContent(org.apache.hadoop.conf.Configuration conf, java.lang.String path)Lists the content of the specified HDFS folder | 
| static org.apache.hadoop.fs.FSDataInputStream | open(org.apache.hadoop.fs.Path p, org.apache.hadoop.conf.Configuration conf)Opens the specified file. | 
| static boolean | validatePathExistence(org.apache.hadoop.conf.Configuration conf, java.lang.String path)Validates if the specified HDFS path exists | 
public static java.io.File copyFromHDFStoLocal(java.lang.String hdfsFile,
                                               java.lang.String localFile,
                                               org.apache.hadoop.conf.Configuration conf)
                                        throws java.io.FileNotFoundException,
                                               java.io.IOException
hdfsFile - path to source HDFS filelocalFile - path to destiny local fileconf - configuration object used to get access to HDFSjava.io.FileNotFoundException - if the file could not be copied to local filesystemjava.io.IOException - if there is a problem during read of source file or write of final local file system
public static boolean validatePathExistence(org.apache.hadoop.conf.Configuration conf,
                                            java.lang.String path)
                                     throws java.io.IOException
conf - Hadoop HDFS configuration to get access into file systempath - path to validate if exists or notjava.io.IOException - if there is a problem while trying to access the path
public static org.apache.hadoop.fs.FileStatus[] listFolderContent(org.apache.hadoop.conf.Configuration conf,
                                                                  java.lang.String path)
                                                           throws java.io.IOException
conf - Hadoop configuration object used to get access to HDFSpath - path to folder containing items to listjava.io.IOException - if there is a problem during the access to the folder
public static org.apache.hadoop.fs.Path getHomeHDFSDirectory(org.apache.hadoop.conf.Configuration conf)
                                                      throws java.io.IOException
conf - Hadoop configuration object used to get access to HDFSjava.io.IOException - if there is a problem during access to this folder
public static void deleteFile(java.lang.String path,
                              org.apache.hadoop.conf.Configuration conf)
                       throws java.io.IOException,
                              java.io.FileNotFoundException
path - path to the file object of deletionconf - Hadoop configuration object used to get access to HDFSjava.io.IOException - if there is problem during access to the specified filejava.io.FileNotFoundException - if the specified file to delete does not exist
public static org.apache.hadoop.fs.FileStatus getFile(java.lang.String path,
                                                      org.apache.hadoop.conf.Configuration conf)
                                               throws java.io.IOException,
                                                      java.io.FileNotFoundException
path - path to the HDFS file that is specified to be selectedconf - Hadoop configuration object used to get access to HDFSjava.io.IOException - if there is problem during access to the specified filejava.io.FileNotFoundException - if the specified file to get does not exist
public static org.apache.hadoop.fs.FileStatus[] getFiles(org.apache.hadoop.fs.Path hdfsPath,
                                                         org.apache.hadoop.conf.Configuration conf)
                                                  throws java.io.IOException,
                                                         java.io.FileNotFoundException
hdfsPath - path of the HDFS folder to pull files fromconf - Hadoop configuration object used to get access to HDFSjava.io.IOException - if there is problem during access to the specified filejava.io.FileNotFoundException - if the specified folder to access does not existpublic static org.apache.hadoop.conf.Configuration getConf(org.apache.hadoop.fs.FileSystem fs)
fs - the HDFS to pull configuration fromConfiguration object attached to the specified HDFS
public static org.apache.hadoop.fs.FSDataInputStream open(org.apache.hadoop.fs.Path p,
                                                          org.apache.hadoop.conf.Configuration conf)
                                                   throws java.io.IOException,
                                                          java.io.FileNotFoundException
p - path to the HDFS file to openconf - Hadoop configuration object used to get access to HDFSjava.io.IOException - if there is problem during access to the specified filejava.io.FileNotFoundException - if the specified folder to access does not existCopyright © 2016 Oracle and/or its affiliates. All Rights Reserved.