我正在尝试从服务器获取文件并将其存储在我的应用程序的 sd 卡中。我收到一个无效的参数错误。
请参阅下面的附加代码和 logcat。请帮助
另外,有没有更好的方法来做到这一点。我也经常遇到套接字超时异常
File file = new File(getExternalFilesDir(null),values);
URL url = new URL("http://abcd.com/edmuploads/"+values);
URLConnection urlConnection = url.openConnection();
urlConnection.setReadTimeout(7000);
urlConnection.setConnectTimeout(7000);
InputStream inputStream = urlConnection.getInputStream();
BufferedInputStream bufferinstream = new BufferedInputStream(inputStream);
ByteArrayBuffer baf = new ByteArrayBuffer(5000);
int current = 0;
while((current = bufferinstream.read()) != -1){
baf.append((byte) current);
}
//This is where I am getting an invalid argument error. The line number 560 as mentioned in the logs below
FileOutputStream fos = new FileOutputStream(file, false);
fos.write(baf.toByteArray());
fos.flush();
fos.close();
原木猫
08-06 10:15:37.089: W/System.err(11448): java.io.FileNotFoundException: /mnt/sdcard/Android/data/com.veleztechnologies.eldicciomalopremium/files/1375701341.3gp
08-06 10:15:37.089: W/System.err(11448): (Invalid argument)
08-06 10:15:37.099: W/System.err(11448): at org.apache.harmony.luni.platform.OSFileSystem.open(Native Method)
08-06 10:15:37.099: W/System.err(11448): at dalvik.system.BlockGuard$WrappedFileSystem.open(BlockGuard.java:232)
08-06 10:15:37.099: W/System.err(11448): at java.io.FileOutputStream.<init>(FileOutputStream.java:94)
08-06 10:15:37.099: W/System.err(11448): at com.veleztechnologies.eldicciomalopremium.WordListActivity.getFileList(WordListActivity.java:560)