Lines i get for downloading 1file:
- Code: Select all
max1
Value:1.jpg
Root:/web/../..
/web/../../1.jpg
Directory:/web/../..
In:org.apache.commons.net.io.SocketInputStream@ee3aa7
Lines i get downloading more files:
- Code: Select all
max2
Value:1.jpg
Value:aboutaction.html
Root:null
/web/../../1.jpg
Directory:/web/../..
In:null
Error: java.lang.NullPointerException
So you see the Root is different but i don't know how it comes.
Here is the code when i pres for downlaoding:
- Code: Select all
else if (evt.getSource() == bDownload)
{
try{
int maxRows;
int[] selRows;
selRows = table1.getSelectedRows();
maxRows = table1.getSelectedRowCount();
System.out.println("max"+maxRows);
if (selRows.length > 0) {
for (int a = 0; a < maxRows; a++){
for (int i= 0; i < 3 ; i++) {
TableModel tm = table1.getModel();
size2 = tm.getValueAt(selRows[a],2);
if (i==1){
value = tm.getValueAt(selRows[a],i);
System.out.println("Value:" + value);
threadDownload((String) value);
}
}
}
}
} catch (Exception e){System.out.println(e.toString());}
}
Then here is the thread:
- Code: Select all
public synchronized void threadDownload(final String valueString) {
new Thread(new Runnable() {
public void run() {
try{
wrapper.changeWorkingDirectory(Root);
System.out.println("Root:" +wrapper.printWorkingDirectory());
Object size = size2;
doDownload(valueString,size);
}
catch (Exception e){}
}
}).start();
}
Here is the code for uploading the file:
- Code: Select all
public synchronized void doDownload(String myValue,Object size2) {
try {
//wrapper.changeWorkingDirectory(Root);
lUpload.setText("Downloading file : " + myValue);
lUpload.setVisible(true);
aProgressBar.setVisible(true);
aProgressBar.setStringPainted(true);
bDownload.setEnabled(false);
bUpload.setEnabled(false);
bMkdirC.setEnabled(false);
bMkdirS.setEnabled(false);
table.setEnabled(false);
table1.setEnabled(false);
bFindLoc.setEnabled(false);
bFindSer.setEnabled(false);
remoteFileName = Root + "/" + myValue;
//remoteFileName = myValue;
localFileName = path + "/" + myValue;
byte[] buffer = new byte[1024];
String size8 = size2.toString();
int size = Integer.parseInt(size8);
aProgressBar.setMaximum(100);
FileOutputStream out = new FileOutputStream(localFileName);
System.out.println(remoteFileName);
System.out.println("Directory:" +wrapper.printWorkingDirectory());
InputStream in = wrapper.retrieveFileStream(remoteFileName);
System.out.println("In:"+in);
int counter = 0;
double bytesDown = 0;
int percVal = 0;
while ((counter = in.read(buffer)) >= 0 ) {
bytesDown += counter;
out.write(buffer,0,counter);
percVal = (int) ((bytesDown / size) * 100);
aProgressBar.setValue(percVal);
aProgressBar.setString("" + percVal + "%");
if (percVal == 100){
refreshDownload();
refreshUpload();
}
}
out.close();
in.close();
} catch (Exception ex) {
System.out.println("Error: " + ex.toString()+ " message: " + ex.getMessage());
}
}
Hope you can help me
Satanduvel


