On Fri, May 8, 2009 at 1:59 AM, Todd Lipcon <t...@cloudera.com> wrote:
> On Thu, May 7, 2009 at 1:26 PM, Foss User <foss...@gmail.com> wrote:
>
>> I was trying to write a Java code to copy a file from local system to
>> a file system (which is also local file system). This is my code.
>>
>> package in.fossist.examples;
>>
>> import java.io.File;
>> import java.io.IOException;
>> import org.apache.hadoop.conf.Configuration;
>> import org.apache.hadoop.fs.Path;
>> import org.apache.hadoop.fs.LocalFileSystem;
>> import org.apache.hadoop.fs.FileUtil;
>>
>> public class FileOps
>> {
>>    public static void main(String[] args) throws IOException
>>    {
>>        FileUtil.copy(new File("a.txt"),
>>                      new LocalFileSystem(),
>>
>
> You can't create a FileSystem like this. You should do something like:
>
> Path src = new Path("a.txt");
> Path dst = new Path("b.txt");
> Configuration conf = new Configuration();
>
> FileUtil.copy(src.getFileSystem(conf), src, dst.getFileSystem(conf), dst,
> false, conf);

This does not work for me as you are reading the "a.txt" from the DFS
while I want to read the "a.txt" from the local file system. Also, I
do not want to copy the file to the distributed file system. Instead I
want to copy it to LocalFileSystem.

Reply via email to