tags:

views:

16

answers:

2

I have made an app that have to copy a file from a webpage, the following code doesn't do the job, it can't find the file

File ekstern = new File("http://192.168.13.40/cache.manifest");

copyFile(ekstern, intern);

and the copyFile method:

    public static void copyFile(File in, File out) throws IOException {
        FileChannel inChannel = new
            FileInputStream(in).getChannel();
        FileChannel outChannel = new
            FileOutputStream(out).getChannel();
        try {
            inChannel.transferTo(0, inChannel.size(),
                        outChannel);
        } 
        catch (IOException e) {
            throw e;
        }
        finally {
            if (inChannel != null) inChannel.close();
            if (outChannel != null) outChannel.close();
        }
   }

But the code says that the file doesn't exists

testing with ekstern.exists()

A: 

You can't use File object to get something from a webpage. You have to use an HttpClient

Falmarri
ok, do you have a link ???
Dennis Dupont
A: 

I found some of the answer here http://www.bogotobogo.com/Android/android23HTTP.html

Now I just need to create a file from the stream

Dennis Dupont