get content from website with utf8 format

Posted by zahir on Stack Overflow See other posts from Stack Overflow or by zahir
Published on 2010-04-06T04:52:13Z Indexed on 2010/04/06 5:23 UTC
Read the original article Hit count: 232

Filed under:
|

i want how to get the content from websites with utf8 format,,

i have writing the following code is

try {
        String webnames = "http://pathivu.com";

        URL url = new URL(webnames);

        URLConnection urlc = url.openConnection();

        //BufferedInputStream buffer = new BufferedInputStream(urlc.getInputStream());
        BufferedReader buffer = new BufferedReader(new InputStreamReader(urlc.getInputStream(), "UTF8"));

        StringBuilder builder = new StringBuilder();

        int byteRead;

        while ((byteRead = buffer.read()) != -1)
            builder.append((char) byteRead);

        buffer.close();

        String text=builder.toString();

        System.out.println(text);
    } 
catch (IOException e) 
{
    e.printStackTrace();

}

but i cant get the correct format...

thanks and advance..

© Stack Overflow or respective owner

Related posts about java

Related posts about utf-8