简体   繁体   中英

file read, write and save

I use java to read a file from a path and want to send it via jms. that works so far, but I need to save it to a different path (to a directory, not as file, cause there are multiple files to load and save.) I kinda know I can just save the message. But I have no idea how that works.

Writer output = new BufferedWriter(new FileWriter(archive));

That's the snipplet that I tried. but I can't write to the archive (access denied) even though I have complete access to everything. Thanks for any help! EDIT!!

for (File x1 : files){
                i++;
                x1.toString();
                String t ;
                FileOutputStream br = new FileOutputStream(x1+"2");

works now with getName, but if i have test.xml it returns test.xml2 how can i fix that?

that's how it works!

for (File x1 : files){
                i++;
                String x2=x1.getName().replaceAll(".xml", "").toString();
                FileOutputStream br = new FileOutputStream(archive+x2+"2"+".xml");

fyi archive is just the filepath where it schould be archived ;D

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM