I have a file set in this folder "C:...../users" (is not real)

I want to change the file path with code to set at "D:...../users"

how can I do that?

I want to change the path of a pic. after import it in database, change her file. how can I do that?

Recommended Answers

All 8 Replies

Do you mean you want to MOVE the file from C: to D: ?

Hi James, yes. I want to move it to a specific other location

The new Java IO classes (Path & Files) include a method to do exactly that.
https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#move-java.nio.file.Path-java.nio.file.Path-java.nio.file.CopyOption...-
You may need a little time to understand the differences between NIO ("New I/O") and the old File class, but it's worth the effort.
https://docs.oracle.com/javase/tutorial/essential/io/fileio.html

Im sorry James, but I did not understood too much from that topic, Im still reading it but not really useful. maybe could specify any location where to read it.

can you write a code for me please?

@altjen The people of DaniWeb are here to assist you in making your code by giving examples/hinting at what you are doing wrong. They don't just make code for you. Also, I feel like doing this manually would be a lot easier, and would probably save time in the long run.

I archive to make this

Files.move(Paths.get("C:\\Users\\Altjen...\\te2.png"), Paths.get("C:\\Users\\Altjen\\Desktop\\Data\\"+jTextField1.getText()+".png"));

it work

yea thats my problem. I just got 19, and still rush too much. by time passing Im understanding that trying to learn Java in the some way like I learned VB would be great. I learn just by trying how the code goes, simple searches in google, and view other people topics.

guess I wont make post like this anymore, will see what I can, after I find a problem that I finally cant pass then I will try to make a topic

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.