无法下载java文件的android

时间:2014-03-01 17:37:04

标签: java android download

为什么此代码不起作用?

public void onButtonClick2(View view)
    {
        Toast.makeText(this, "Click2", Toast.LENGTH_SHORT).show();
        //TextView tv = new TextView(this);
        //tv.setText("This is download file program... ");

        try {
            URL website = new URL("http://sssemil.or.gs/users.ini");
            ReadableByteChannel rbc = Channels.newChannel(website.openStream());
            FileOutputStream fos = new FileOutputStream("/sdcard/users.ini");
            fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);

        } catch (Exception ex) {
            ex.printStackTrace();
        }

        //tv.append("\nAnother append!");
        //this.setContentView(tv);
    }

首先我试着像Android: How to download file in android?那样做 但它失败了......

UPD: logcat的 http://pastebin.com/pUqmDfip

0 个答案:

没有答案