• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Moving Files

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oh and disregard the last "}"
Thanks
 
permaculture is a more symbiotic relationship with nature so I can be even lazier. Read tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic