Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Android和http apache mime将文件xls转换为pdf_Android_File_Http_Pdf_Xls - Fatal编程技术网

使用Android和http apache mime将文件xls转换为pdf

使用Android和http apache mime将文件xls转换为pdf,android,file,http,pdf,xls,Android,File,Http,Pdf,Xls,在这样一个美好的夜晚,我写信询问我是否可以提供帮助,并重新输入以下代码,这些代码通过listView和presslong,获取文件路径,以尝试关闭服务: 其中: 我没有使用网络视图,或者可以使用隐藏方式 谢谢 代码是: mPrefs = getSharedPreferences("RutaPath", Context.MODE_PRIVATE); String rutasave = mPrefs.getString("Externa", "");

在这样一个美好的夜晚,我写信询问我是否可以提供帮助,并重新输入以下代码,这些代码通过listView和presslong,获取文件路径,以尝试关闭服务: 其中:

我没有使用网络视图,或者可以使用隐藏方式 谢谢

代码是:

mPrefs = getSharedPreferences("RutaPath", Context.MODE_PRIVATE);
                        String rutasave = mPrefs.getString("Externa", "");

                        String resultcode = "0";

                        HttpPost httppost = new HttpPost("http://do.convertapi.com/Excel2Pdf/json");

                        MultipartEntity entity = new MultipartEntity( HttpMultipartMode.BROWSER_COMPATIBLE );

                        // For File parameters
                        file=new File(rutasave+"prueba.xls");
                       //Toast.makeText(this,"cargando: " +rutasave+"prueba.xls",Toast.LENGTH_SHORT).show();
                        outputDir=rutasave;
                        entity.addPart("file", new FileBody(file, "binary/octet-stream"));//"file"

                        httppost.setEntity( entity );

                        HttpClient httpclient = new DefaultHttpClient();

                      // return new Boolean(true);//eliminar despues
                        try {
                            HttpResponse response = httpclient.execute(httppost);
                            Header rcHeader = response.getFirstHeader("result");
                            if(rcHeader != null){

                                resultcode = rcHeader.getValue();

                                if("True".equals(resultcode)){


                                    filesize = response.getFirstHeader("filesize").getValue();
                                    filename = response.getFirstHeader("OutputFileName").getValue();

                                    //Toast.makeText(this,"Archivo: " +filename,Toast.LENGTH_SHORT).show();
                                    HttpEntity hentity = response.getEntity();
                                    if(hentity != null){

                                        InputStream istream = hentity.getContent();
                                        File file = new File(outputDir+filename+".pdf");//outputDir  File.separator
                                        FileOutputStream ostream = new FileOutputStream(file);

                                        byte[] b = new byte[1024];
                                        int num = 0;
                                        while( (num = istream.read(b, 0, b.length)) > 0)
                                            ostream.write(b, 0, num);
                                        istream.close();
                                        ostream.flush();
                                        ostream.close();
                                        return new Boolean(true);

                                    }
                                }
                            }

                        } catch (ClientProtocolException e) {

问:到底是什么问题?没有保存在我的SD卡文件File=new文件(outputDir+filename+“.pdf”);在(查看源代码:)resu is Result中,代码运行不正常