I want to Copy an xml file from one directory to other directory. I've used Files.copy(source, target, REPLACE_EXISTING).But i am getting it as a text file.I want it as xml. Please help.
Asked
Active
Viewed 1,811 times
1
-
3XML file is text file – Andremoniy Jan 19 '17 at 13:00
-
Please add your code (and not just the function's name). – Yogev Levy Jan 19 '17 at 13:00
-
could you please paste some of your code? – Avinash Anand Jan 19 '17 at 13:00
-
Source and Destination are in different drives.Is this possible? – pparitala Jan 19 '17 at 13:05
-
File input = new File("C:\\channels\\AllState\\moretrench\\Test.Allstate.Moretrench_Environmental_Services - Copy.xml"); File destFile1 = new File("D:\\New folder\\AllState\\moretrench\\Test.Allstate.Moretrench_Environmental_Services - Copy.xml"); Files.copy(input.toPath(), destFile1.toPath(),REPLACE_EXISTING); – pparitala Jan 19 '17 at 13:06
-
Thanks for the accept! – GhostCat Jan 24 '17 at 10:17
1 Answers
0
In case you are asking: "I got a text file A.txt in one directory, and I want to represent the content of that file as some B.xml in another directory" ... well, then simple: you will have to
- parse that text file (identify the information within)
- decide how to "model" that in an XML like document structure
- write that as XML
There is simply no generic way of transforming any kind of "text" into XML.

GhostCat
- 137,827
- 25
- 176
- 248
-
-
Sorry, but then your question doesn't make much sense. You got two files, and you already mentioned that you know how to copy them using Java library calls. So *what* is your problem then?! – GhostCat Jan 19 '17 at 13:52
-