在Android 6.0版中查看下载的Pdf文件未显示数据

时间:2016-01-14 12:11:37

标签: android pdf pdf-generation android-6.0-marshmallow

我在下面从服务器下载pdf文件并在sdcard中存储在版本低于6.0的设备中正常工作但在Nexus版本6.0中下载的pdf文件显示一些数据为三个点。

 public static void DownloadFile(String fileUrl, File directory) {
        try {
            fileUrl = fileUrl.replace(" ", "%20");
            URL url = new URL(fileUrl);
            HttpURLConnection urlConnection = (HttpURLConnection)                                 url.openConnection();
            //urlConnection.setRequestMethod("GET");
            //urlConnection.setDoOutput(true);
            urlConnection.connect();
            InputStream inputStream = urlConnection.getInputStream();
            FileOutputStream fileOutputStream = new FileOutputStream(directory);
            int totalSize = urlConnection.getContentLength();
            byte[] buffer = new byte[1024 * 1024];
            int bufferLength = 0;
            while ((bufferLength = inputStream.read(buffer)) > 0) {
                fileOutputStream.write(buffer, 0, bufferLength);
            }
            fileOutputStream.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

Below marshmallow In marshmallow

请有人知道如何解决这个问题吗?

0 个答案:

没有答案