小编nat*_*han的帖子

HttpURLConnection java.io.FileNotFoundException

如果我连接到似乎是Apache服务器的代码,下面的代码工作得很好,但是当我尝试连接到我的.Net服务器时,它会抛出错误.我猜这是一个标题要求,但无论我尝试什么,我似乎无法得到成功的回应.

public String Download(String Url)
{
 String filepath=null;
 try {
  //set the download URL, a url that points to a file on the internet
  //this is the file to be downloaded
  URL url = new URL(Url);
  //create the new connection
  HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();

  //set up some things on the connection
  urlConnection.setRequestMethod("GET");
  urlConnection.setDoOutput(true); 
   //and connect!
  urlConnection.connect();
  //set the path where we want to save the file
  //in this case, going to save it on the root directory of the …
Run Code Online (Sandbox Code Playgroud)

android download filenotfoundexception httpurlconnection

44
推荐指数
2
解决办法
7万
查看次数