Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7629583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:52:18+00:00 2026-05-31T05:52:18+00:00

I need to fetch HTML from Turkish webpages using Java. However, I am finding

  • 0

I need to fetch HTML from Turkish webpages using Java. However, I am finding that my Java code is not able to pick up certain Turkish characters. Here is the Java code I am using:

import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.InputStream;
import java.net.URL;

public class fetchHTML {
public static void main(String[] args) throws Exception {

    URL urls = new URL("http://www.parkbravo.com.tr/pantolon.php");
    InputStream is = urls.openStream();  
    DataInputStream dis = new DataInputStream(new BufferedInputStream(is));

    String line;

    while ((line = dis.readLine()) != null) {
        System.out.println(line);
    }
}
}

The first few lines of output of this code are:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />
<html lang="tr" xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<title>ParkBravo - Ãrünler - Pantolonlar</title>

You can see that the title is incorrect: Ãrünler should be Ürünler

If I use the following Python code to get the HTML:

import urllib2

url = 'http://www.parkbravo.com.tr/pantolon.php' 

usock = urllib2.urlopen(url)
data = usock.read()
usock.close()

print data

then the output is correct. Title comes out as:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />
<html lang="tr" xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<title>ParkBravo - Ürünler - Pantolonlar</title>

But I want to be able to get the HTML with Java. Does anyone know how I can get this working?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:52:19+00:00Added an answer on May 31, 2026 at 5:52 am

    readLine() in DataInputStream is Deprecated. You should use a Reader, which handles the conversion from bytes to characters correctly.

    If you use InputStreamReader, you can specify the encoding in the constructor and if you wrap it in BufferedReader, you can read lines.

    Instead of

     DataInputStream dis = new DataInputStream(new BufferedInputStream(is));
    

    you can have

     BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"))
    

    Where “UTF-8” can be replaced by whatever encoding you need.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to run some code that will fetch some configuration values from the
i need to fetch a url with javascript/jquery and not php. i've read that
Im using vb.net and I need to fetch data from two different tables and
I need to put the values retrieved using a Fetch Request from my core
Here's what I need to fetch: - posts that have comments - number of
What do I do, I need to fetch data from 3 tables in mysql,
I need to know, how to fetch class name from div instead of id
I want to call a method asynchronically. It's a method that gets HTML from
Original format: <a href=http://www.example.com/t434234.html ...> 1. I need to fetch all URLs of this
I need to retrieve some some raw HTML from a certain part of an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.