2015-07-10 41 views
0

我写了这样的代码。用Http Request和UTF-8下载文件

 URL obj = new URL(url); 
     HttpURLConnection con = (HttpURLConnection) obj.openConnection(); 


     con.setRequestMethod("GET"); 

     con.setRequestProperty("Cache-Control", "no-cache"); 


     int responseCode = con.getResponseCode(); 



      InputStream inputStream = con.getInputStream(); 
       FileOutputStream outputStream = new  FileOutputStream("C:\\aaaa\\ww.csv"); 

       int bytesRead = -1; 
      byte[] buffer = new byte[4096]; 
      while ((bytesRead = inputStream.read(buffer)) != -1) { 
       outputStream.write(buffer, 0, bytesRead); 
      } 

      outputStream.close(); 
      inputStream.close(); 

代码工作well.I发送请求,我可以下载csv文件到我computer.But我想知道,如果CSV文件有土耳其字符(S,G,I,C)我可以用该字符下载csv。

或什么可以为那些字符在csv文件中看到它们。

+0

您是否尝试过使用土耳其字符?怎么了?请求文档与浏览器和您的代码有区别吗?响应中的内容类型和字符编码标头的值是什么?它是什么样的服务器?你拥有服务器吗? – vanje

回答

0

服务器向您发送字节流,您只需将字节流保存在磁盘上,这样您就不必担心字符。