有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java解析Android应用程序中tornado web服务中的CSV文件

我有Tornado web服务,它在创建CSV文件后返回一个链接,如下所示

http://10.0.2.2:8000/uploads/16165159GyjFImAYZssLEmn/16165159GyjFImAYZssLEmn.csv

我还成功地在Android应用程序中输出了这个URL。我的问题是如何使用上面显示的URL解析此文件的数据。我尝试了很多方法,但都没有成功。谁能帮我解决这个问题吗。到目前为止,我掌握的代码如下

我也提到了thispost,但仍然没有成功

    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httpPost = new HttpPost(modifyURL);   
    HttpResponse httpResponse = httpclient.execute(httpPost);
    responseEntity = httpResponse.getEntity();
    transformedImageURL = EntityUtils.toString(responseEntity);

    URL url = new URL(transformedImageURL);
    InputStream stream = url.openStream();
    BufferedInputStream bis = new BufferedInputStream(stream);
    ByteArrayBuffer baf = new ByteArrayBuffer(200);

    nt current = 0;

    while((current - bis.read()) != -1){
           baf.append((byte) current);
    }

    String stockText = new String(baf.toByteArray());
    String[] tokens = stockText.split(",");
    String testData = tokens[0];

谢谢你抽出时间


共 (0) 个答案