-1

我想以字符串数组而不是文本形式发送结果。这是以文本形式发送结果的代码。但我想以字符串数组形式发送结果。

ChannelSftp sftpChannel = (ChannelSftp) channel;

try {
    Vector ls=sftpChannel.ls("/home/abc/Desktop");

    for(int i = 0; i < ls.size(); i++) {
        text += sftpChannel.pwd() + "/" + (((LsEntry)ls.get(i)).getFilename()) + "\n";
    }

    t.post(new Runnable() {
        public void run() { t.setText(text); }
    });

    } catch (SftpException e1) { }
4

1 回答 1

0
ChannelSftp sftpChannel = (ChannelSftp) channel;

try {
    Vector ls=sftpChannel.ls("/home/abc/Desktop");
    String[] strings = new String[ls.size];

    for(int i = 0; i < ls.size(); i++) {
        strings[i] = sftpChannel.pwd() + "/" + (((LsEntry)ls.get(i)).getFilename());
    }

    t.post(new Runnable() {
        public void run() { t.setText(strings.toString()); }
    });

    } catch (SftpException e1) { }
于 2012-11-21T13:16:03.027 回答