只是能显示..
first test
second test
before seven
seven test
eight testprotected void listFTPFile() {
DefaultListModel model = new DefaultListModel();
String strTemp="", token="", path="";
boolean isDirectory = false;
try {
this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
this.statusBar.setText("Status: Listing...");
lstRemote.setModel(model);
sun.net.TelnetInputStream input = ftpclient.list();
model.addElement(".."); model.addElement("First test");
while (true) {
int c = input.read();
char ch = (char) c;
//for (; c > 0; ) { if (c < 0 || ch == '\n') {
StringTokenizer stringtoken = new StringTokenizer(strTemp);
int index = 0; model.addElement("Second test "); while (stringtoken.hasMoreTokens()) {
token = stringtoken.nextToken(); model.addElement("Third test in the while loopup "); if (index == 2) {
if (token.equalsIgnoreCase("<DIR>"))
isDirectory = true;
else
isDirectory = false; model.addElement("Four test in the index==2"); } if (index == 3) {
if (isDirectory)
path = token + "/";
else
path = token; model.addElement("Five test in the index==3"); model.addElement(path); }
index++; model.addElement("Six test in out of index++"); }
strTemp = "";
model.addElement(strTemp+"before seven");
model.addElement("Seven test "); }
if (c <= 0)
break;
strTemp += ch;
model.addElement(strTemp+"after seven");
}
model.addElement("Eight test"); input.close();
lstRemote.setModel(model);
this.statusBar.setText("status: List complete.");
} catch (IOException ioex) {
this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
ioex.printStackTrace();
}
catch (Exception ex) {
this.statusBar.setText("Status: upload" + localfile + "fail.");
ex.printStackTrace();
}
this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); }
first test
second test
before seven
seven test
eight testprotected void listFTPFile() {
DefaultListModel model = new DefaultListModel();
String strTemp="", token="", path="";
boolean isDirectory = false;
try {
this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
this.statusBar.setText("Status: Listing...");
lstRemote.setModel(model);
sun.net.TelnetInputStream input = ftpclient.list();
model.addElement(".."); model.addElement("First test");
while (true) {
int c = input.read();
char ch = (char) c;
//for (; c > 0; ) { if (c < 0 || ch == '\n') {
StringTokenizer stringtoken = new StringTokenizer(strTemp);
int index = 0; model.addElement("Second test "); while (stringtoken.hasMoreTokens()) {
token = stringtoken.nextToken(); model.addElement("Third test in the while loopup "); if (index == 2) {
if (token.equalsIgnoreCase("<DIR>"))
isDirectory = true;
else
isDirectory = false; model.addElement("Four test in the index==2"); } if (index == 3) {
if (isDirectory)
path = token + "/";
else
path = token; model.addElement("Five test in the index==3"); model.addElement(path); }
index++; model.addElement("Six test in out of index++"); }
strTemp = "";
model.addElement(strTemp+"before seven");
model.addElement("Seven test "); }
if (c <= 0)
break;
strTemp += ch;
model.addElement(strTemp+"after seven");
}
model.addElement("Eight test"); input.close();
lstRemote.setModel(model);
this.statusBar.setText("status: List complete.");
} catch (IOException ioex) {
this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
ioex.printStackTrace();
}
catch (Exception ex) {
this.statusBar.setText("Status: upload" + localfile + "fail.");
ex.printStackTrace();
}
this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); }
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货