谁能解释文件()参数用来下载文件中的Andr​​oid? [英] Can anyone explain the File() parameters used to download file in android?

查看:131
本文介绍了谁能解释文件()参数用来下载文件中的Andr​​oid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在参考这个的Andr​​oid文件下载的问题。

In Reference to this android file download problem

谁能解释一下这是否意味着线在code

Can anyone explain what does this line mean in the code

FileOutputStream f = new FileOutputStream(new File(root,"Video.mp4"));

和这是什么的文件中所指的参数根()

我是否需要指定根路径来保存文件?

Do I need to specify the root path to save the file?

如果是的话,那么我们如何指定的android的根路径?

If it is the case then how do we specify the root path in android ?

问候

推荐答案

的<一个href=\"http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html#File%28java.io.File,%20java.lang.String%29\"相对=nofollow> java.io.File中(文件,字符串)或<一个href=\"http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html#File%28java.lang.String,%20java.lang.String%29\"相对=nofollow> java.io.File中(字符串,字符串)是Java的标准Java构造函数。第一个参数就是父目录路径,而第二个是实际的文件名。如果该文件是在当前工作目录或你认识的完整路径作为一个字符串可以避开2参数构造函数。

The java.io.File(File, String) or java.io.File(String, String) are standard java constructors for Java. The first argument is just the parent directory path, while the second is the actual file name. If the file is in the current working directory or you know the full path as one string you can avoid the 2 argument constructors.

由于您要下载的文件你可以通过正常URL.openStream获取文件()来获得一个InputStream,让您下载的文件的内容。对于写出来的数据,你会跟你联系到写内容的例子。

Since you are trying to download a file you can just acquire the file through a normal URL.openStream() to get an InputStream to get the contents of your downloaded file. For writing the data out you will follow the example you linked to to write the contents.

我不确定的的变量是指出,在这个例子是什么。我不能帮助你超越这虽然因为我只通过第一你好走了,Android的例子我自己。

I'm unsure what the root variable was pointed to in the example. I'm not able to help you beyond this though since I have only gone through the first Hello, Android example myself.

这篇关于谁能解释文件()参数用来下载文件中的Andr​​oid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆