hadoop-hdfs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From João Alves <j...@5dlab.com>
Subject Re: FileUtil Copy example
Date Thu, 25 Sep 2014 06:48:43 GMT
Hey Susheel,

Maybe it would be a good idea to check if the string is long enough for your substring operation.
(i.e. fstatus[i].getPath().getName().length() >= 10)

 
On 25 Sep 2014, at 07:14, Susheel Kumar Gadalay <skgadalay@gmail.com> wrote:

> I solved it like this. This will move a file from one location to
> another location.
> 
> FileStatus[] fstatus = FileSystem.listStatus(new Path(<Old HDFS directory>));
> for (int i=0; i<fstatus.length; i++) {
>   if (fstatus[i].isFile()) {
>      if (fstatus[i].getPath().getName().substring(0,
> 10).matches("<some name>"))
>         FileSystem.rename(new Path(<Old HDFS Directory> + "/" +
> fstatus[i].getPath().getName()), new Path(<New HDFS Directory> + "/" +
> fstatus[i].getPath().getName()));
>   }
> }
> 
> I don't think copy individual file API is available.
> 
> 
> On 9/23/14, Susheel Kumar Gadalay <skgadalay@gmail.com> wrote:
>> Can somebody give a good example of using Hadoop FileUtil API to copy
>> set of files from one directory to another directory.
>> 
>> I want to copy only a set of files not all files in the directory and
>> also I want to use wild character like part_r_*.
>> 
>> Thanks
>> Susheel Kumar
>> 


Mime
View raw message