You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-user@hadoop.apache.org by "W.P. McNeill" <bi...@gmail.com> on 2011/03/28 22:17:52 UTC

How do I programmatically delete an HDFS file from Java?

I have a Hadoop job that creates a temporary sequence file at a path it gets
from FileOutputFormat.getPathForWorkFile(). On successful completion of the
job, I'd like to delete the file, but I can't figure out how.

Is there an HDFS temporary file API with automatic cleanup?  In failing that
is there a way I can programmatically delete the file when I'm done with it?

These seem like basic questions, but I haven't been able to find the answers
in the O'Reilly book or online.

Re: How do I programmatically delete an HDFS file from Java?

Posted by "W.P. McNeill" <bi...@gmail.com>.
Never mind.  I overlooked the link that says the non-deprecated version is
FileSystem.delete(Path, BOOLEAN).

I'm still curious if there is a an automatically self-cleaning temporary
file system.

On Mon, Mar 28, 2011 at 2:41 PM, W.P. McNeill <bi...@gmail.com> wrote:

> FileSystem.delete(Path) appears to be deprecated in the new API.  Is there
> a non-deprecated way to do this.
>
>
> On Mon, Mar 28, 2011 at 1:28 PM, Harsh J <qw...@gmail.com> wrote:
>
>> Generally you can delete files on any hadoop-used FS using a suitable
>> FileSystem.delete(Path) call. Would this work for you?
>>
>> I'm not aware of any auto temporary-create-and-delete functionality
>> though. Would be good to know if this too exists inside Hadoop's libs.
>>
>> On Tue, Mar 29, 2011 at 1:47 AM, W.P. McNeill <bi...@gmail.com> wrote:
>> > These seem like basic questions, but I haven't been able to find the
>> answers
>> > in the O'Reilly book or online.
>>
>> Tom White's book covers the deleting part at least. Check it out:
>> Chapter 3 (HDFS) -> Java Interface -> Deleting Data.
>>
>> --
>> Harsh J
>> http://harshj.com
>>
>
>

Re: How do I programmatically delete an HDFS file from Java?

Posted by "W.P. McNeill" <bi...@gmail.com>.
FileSystem.delete(Path) appears to be deprecated in the new API.  Is there a
non-deprecated way to do this.

On Mon, Mar 28, 2011 at 1:28 PM, Harsh J <qw...@gmail.com> wrote:

> Generally you can delete files on any hadoop-used FS using a suitable
> FileSystem.delete(Path) call. Would this work for you?
>
> I'm not aware of any auto temporary-create-and-delete functionality
> though. Would be good to know if this too exists inside Hadoop's libs.
>
> On Tue, Mar 29, 2011 at 1:47 AM, W.P. McNeill <bi...@gmail.com> wrote:
> > These seem like basic questions, but I haven't been able to find the
> answers
> > in the O'Reilly book or online.
>
> Tom White's book covers the deleting part at least. Check it out:
> Chapter 3 (HDFS) -> Java Interface -> Deleting Data.
>
> --
> Harsh J
> http://harshj.com
>

Re: How do I programmatically delete an HDFS file from Java?

Posted by Harsh J <qw...@gmail.com>.
Generally you can delete files on any hadoop-used FS using a suitable
FileSystem.delete(Path) call. Would this work for you?

I'm not aware of any auto temporary-create-and-delete functionality
though. Would be good to know if this too exists inside Hadoop's libs.

On Tue, Mar 29, 2011 at 1:47 AM, W.P. McNeill <bi...@gmail.com> wrote:
> These seem like basic questions, but I haven't been able to find the answers
> in the O'Reilly book or online.

Tom White's book covers the deleting part at least. Check it out:
Chapter 3 (HDFS) -> Java Interface -> Deleting Data.

-- 
Harsh J
http://harshj.com