我已经完成了应用程序的视频文件下载代码及其最高版本 2.3.3 的工作性能,但它在 android 4.0 中无法正常工作,并且出现类似 java.io.FileNotFoundException 的错误任何人都可以帮我解决这个问题问题?提前致谢
public void video_download(String urlstring, String Name) {
URL url;
try {
url = new URL(urlstring);
HttpURLConnection c = (HttpURLConnection) url.openConnection();
c.setRequestMethod("GET");
c.setDoOutput(true);
c.connect();
String PATH = Environment.getExternalStorageDirectory()
+ "/application/";
Log.v("PATH", "PATH: " + PATH);
File file = new File(PATH);
file.mkdirs();
String fileName;
fileName = Name + ".mp4";
File outputFile = new File(file, fileName);
FileOutputStream fos = new FileOutputStream(outputFile);
InputStream is = c.getInputStream();
byte[] buffer = new byte[1024];
int len1 = 0;
while ((len1 = is.read(buffer)) != -1) {
fos.write(buffer, 0, len1);
}
fos.close();
is.close();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}