Hey
I have a folder in my current working path and I want to make a copy of a file inside it to the the current working path. Its kind of a dumb question, I know, but how do it do it?
Thank you.
Hey
I have a folder in my current working path and I want to make a copy of a file inside it to the the current working path. Its kind of a dumb question, I know, but how do it do it?
Thank you.
Hey
I have a folder in my current working path and I want to make a copy of a file inside it to the the current working path. Its kind of a dumb question, I know, but how do it do it?
Thank you.
maybe this:http://edgblog.wordpress.com/2010/02/20/how-to-copy-a-file-in-java/ and this:http://www.java7developer.com/blog/?p=334 and this:http://codingjunkie.net/java-7-copy-move/ just for a variety :P
Java 6 only.
The thing is I cant get the directoy where it saves it which is
"C:\Archivos de programa\MyEclipse for Spring\Common\plugins\com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201109141806\tomcat\bin"
It is driving me nuts.
If Im located there, how would I go up a directory (To "C:\Archivos de programa\MyEclipse for Spring\Common\plugins\com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201109141806\tomcat" ) ?
If Im located there, how would I go up a directory (To "C:\Archivos de programa\MyEclipse for Spring\Common\plugins\com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201109141806\tomcat" ) ?
You could feed the path into [regexp (.+)/.+] to take off the last folder in the path.
[edit] and here's a way to copy in java 6:http://www.roseindia.net/java/beginners/CopyFile.shtml
You could feed the path into [regexp (.+)/.+] to take off the last folder in the path.
How do I do that? Dont understand that exactly....
What is regexp?
Ah, regular expresions......OK.......
But what line exactly would I use? Not too sure...
Ah, regular expresions......OK.......
But what line exactly would I use? Not too sure...
what do you mean what line?
You could also just use a lastIndexOf("\\"), which will get the the position of the last '\' and then you just replace it so then you;d have:C:\Archivos de programa\MyEclipse for Spring\Common\plugins\com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201109141806
what do you mean what line?
You could also just use a lastIndexOf("\\"), which will get the the position of the last '\' and then you just replace it so then you;d have:C:\Archivos de programa\MyEclipse for Spring\Common\plugins\com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201109141806
What instruction line do I use?
Yeah, used lastindex as a alternative I suppose but after finding the path, I cant get it to copy. It says that it cant find the path when the path is perfectly correct as I print it out before I do it and when the exception jumps, the path is exactly the same.....
What could be wrong? Man this is killing me :(
What instruction line do I use?
Yeah, used lastindex as a alternative I suppose but after finding the path, I cant get it to copy. It says that it cant find the path when the path is perfectly correct as I print it out before I do it and when the exception jumps, the path is exactly the same.....
What could be wrong? Man this is killing me :(
well it would help posting your code, and the error message and line number and the output of your new path you are trying...
well it would help posting your code, and the error message and line number and the output of your new path you are trying...
Its a lot of code and kind of complicated but I think it is around here:
String ruta= System.getProperty("user.dir")+ "\\"; //ruta=ruta+ "\\"; System.out.println("La ruta es: " + ruta); System.out.println("Voy a crear un zip " + System.getProperty("user.dir") + " " + binpath + " " + projectpath + " " + realprojectpath ); Crear_Zip z=new Crear_Zip(); String[] trozos=nombreprograma.split("_"); String nombrebmp=trozos[0]+"_"+trozos[1]+"_"+trozos[2]; System.out.println("El string del BMP es: " + nombrebmp); //FileUtils.copyFile(new File(nombreprograma+"\\"+nombrebmp+".bmp"), new File(nombrebmp+".bmp")); System.out.println("Voy a copiar desde: " + ruta+nombreprograma+"\\"+nombrebmp+".bmp"); System.out.println("Voy a copiar ha: " + nombrebmp+".bmp"); //String desde=ruta+nombreprograma+"\\"+nombrebmp+".bmp"; String nuevodesde=realprojectpath+nombreprograma+"/"+nombrebmp+".bmp"; System.out.println("nuevo: " + nuevodesde); FileUtils.copyFile(new File(nuevodesde), new File(nombrebmp+".bmp"));
And there is the output:
La ruta es: C:\Archivos de programa\MyEclipse for Spring\Common\plugins\com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201109141806\tomcat\bin\
Voy a crear un zip C:\Archivos de programa\MyEclipse for Spring\Common\plugins\com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201109141806\tomcat\bin file:/C:/Archivos de programa/MyEclipse for Spring/Common/plugins/com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201109141806/tomcat/lib file:/C:/Archivos de programa/MyEclipse for Spring/Common/plugins/com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201109141806/tomcat/ C:/Archivos de programa/MyEclipse for Spring/Common/plugins/com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201109141806/tomcat/
El string del BMP es: 234_99_165544300
Voy a copiar desde: C:\Archivos de programa\MyEclipse for Spring\Common\plugins\com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201109141806\tomcat\bin\234_99_165544300_1\234_99_165544300.bmp
Voy a copiar ha: 234_99_165544300.bmp
nuevo: C:/Archivos de programa/MyEclipse for Spring/Common/plugins/com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201109141806/tomcat/234_99_165544300_1/234_99_165544300.bmp
Ha fallado: Rollback time!
2012-02-16 JUE 16:55:44.300 : Ha ocurrido un error generico: Source 'C:\Archivos de programa\MyEclipse for Spring\Common\plugins\com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201109141806\tomcat\234_99_165544300_1\234_99_165544300.bmp' does not exist
If Im located there, how would I go up a directory (To "C:\Archivos de programa\MyEclipse for Spring\Common\plugins\com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201109141806\tomcat" ) ?
You don't need all that manual "last index" parsing pain.
Just create a File object to the original dir then use getParent() to give you the parent (one-up) dir.
eg
File f = new File("c:/abc/def/ghi/jk");
System.out.println(f.getParent());
prints
c:\abc\def\ghi
FINALLY......what I did is that I unzipped the file that I originally created by searching for that BMP inside the ZIP file. That creates it back to where I need and i creates the PDF perfectly.
Ive been about a week with this so finally.....
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.