Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Moving Files

 
Tex Abrey
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
Does anyone know how to move files to a different directory using jsp, if even possible. Is there a way i could run a shell command??
Tex
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On server you can do it using standard Java I/O I assume (I've never tried it).
On the client side you aren't going to be able to do it with a jsp or servlet. You might be able to do it with some an applet but the user would have to their security permission set pretty low for that to be allowed.
 
Tex Abrey
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I found something called the renameTO() but when i try using it I get an error that says
"Method renameTO(java.io.File) not found in class java.io.File." Anyone have any idea as to why this is.
I have look up other resources and they all import "java.io.*" and I have done that.
Tex
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should be renameTo(File) with a lowercase o, not an uppercase.
 
Tex Abrey
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanxs i hate it when i miss things like that.
i get no error now it just doesn't work it keeps returning false.
this is my code
String absDIR= "inet/docroot/dabrey/Newsclippings/upload/.";
String absDIR= "inet/docroot/dabrey/Newsclippings/clippings/";
File path = new File(dirURL);
String[] list = path.list();
for(int i = 0; i < list.length; i++) {
String pdfName = list[list.length - 1 - i];
String year = pdfName.substring(0,2) + "/";
String mon = pdfName.substring(3,5) + "/";
String day = pdfName.substring(6,8);
File old = new File(pdfDirURL + pdfName);
File moved = new File(absDIR + year + mon + pdfName);
out.println(moved);

try{
boolean flag = false;
flag = old.renameTo(moved);
out.println(flag);
}
catch(Exception e) {
System.out.println(e);
}
}

Any Clue??
Tex
 
Tex Abrey
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh and disregard the last "}"
Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!