Link to home
Start Free TrialLog in
Avatar of mooy
mooy

asked on

Java File renameTo()

hi ppl,


i stumble upon a problem...im not sure whether it got to do with the encoding..

i have this XML file in "UTF-8" encoding (invoice.xml)

i wan to write a program to change this filename to (invoice.txt) , i am using renameTo() function but the output i see from the txt file have a special character contain in it...

the new line(\n) from the XML file is changed to something like a square bracket ( [] )..

is there any method to simply change the extension of the file?

thnx, this is rather urgent...depends on all of u now
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

>>the new line(\n) from the XML file is changed to something like a square bracket ( [] )..

In what program are you viewing this?
renameTo() wouldn't change the content of the file.

> is there any method to simply change the extension of the file?

renameTo()  :)
Avatar of expertmb
expertmb

renameTo()
it renames the file properly.
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mooy

ASKER

oh i see...

therefore is only when i use Notepad to view the txt file, i get those square thingy...

if i were to parse the txt file, will the square bracket affect it?
>>if i were to parse the txt file, will the square bracket affect it?

No, not unless by 'parsing' you mean some sort of binary manipulation, which i guess you don't ....
> if i were to parse the txt file, will the square bracket affect it?

most probably not :)
>> therefore is only when i use Notepad to view the txt file, i get those square thingy...
You should also see this square character when you view the xml file with Notepad
you see a square character in notepad because windows doesnt know how to handle \n... windows requires \r\n to display a newline, thats the reason for the square character
(which i've already said)
CEHJ, relax, im not looking for expert points... its just that no one mentioned \r\n specifically, so i thought i should add it
ok ;-)
in wordpad, the file would display correctly
Avatar of mooy

ASKER

oh thnx...is the notepad problem...zzz

thnx every one
its got nothing to do with renameTo() either :)
8-)