I have used following code to read a file on web and write it on my computer ,but the text present on the web page is not the same after saved on the computer,
i can't able to find out the cause ,I think the text file uses ANSI format and the web page uses UNICODE or UTF-8 format ,is this the cause why I am geting dfferent out put or any other cause is there,
I wnt to read and save the content the format it has,
if the file is in ANSI then the file should saved in ANSI format
If the file is in other then it should be saved in that format,,
kindly tell me how to get this..
bellow the code i have used but can't able to read and write in actual format
i am getting a file name content_save.txt but in that file the title of the web page and other thing are not same as actual page
If your goal is simply to download the data from a URL, then converting it from bytes to chars and then from chars back to bytes again is (a) a waste of time and (b) likely to mangle your data if you do it wrong.
Which you did do it wrong. You used an InputStreamReader using your system's default charset, whereas the charset of the page is UTF-8 (which you can tell by looking at its contents).
So don't do that. Just copy from the URL's input stream to a FileOutputStream.
And forget about ANSI versus not-ANSI. That isn't a useful concept in the real world where documents can be written with any of several dozen charsets.
Also, when you look at the file you write, don't forget to use a display tool which (a) reads the file using the correct charset and (b) is able to display non-Latin scripts.
Your mother was a hamster and your father was a tiny ad: