करने के लिए सेट एन्कोडिंग मैं से http://api.freebase.com/api/trans/raw/m/0h47जावा UTF-8 नहीं URLConnection
डेटा पुनः प्राप्त करने के लिए आप पाठ में देख सकते हैं इस तरह गाती है देखते हैं कोशिश कर रहा हूँ।
जब मैं ú
आदि
अब तक मैं निम्नलिखित कोड के साथ की कोशिश की है की तरह गाती है के साथ मैं पाठ पाने पेज से स्रोत प्राप्त करने की कोशिश:
urlConnection.setRequestProperty("Accept-Charset", "UTF-8");
urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
क्या मैं गलत कर रहा हूँ?
मेरे पूरे कोड:
URL url = null;
URLConnection urlConn = null;
DataInputStream input = null;
try {
url = new URL("http://api.freebase.com/api/trans/raw/m/0h47");
} catch (MalformedURLException e) {e.printStackTrace();}
try {
urlConn = url.openConnection();
} catch (IOException e) { e.printStackTrace(); }
urlConn.setRequestProperty("Accept-Charset", "UTF-8");
urlConn.setRequestProperty("Content-Type", "text/plain; charset=utf-8");
urlConn.setDoInput(true);
urlConn.setUseCaches(false);
StringBuffer strBseznam = new StringBuffer();
if (strBseznam.length() > 0)
strBseznam.deleteCharAt(strBseznam.length() - 1);
try {
input = new DataInputStream(urlConn.getInputStream());
} catch (IOException e) { e.printStackTrace(); }
String str = "";
StringBuffer strB = new StringBuffer();
strB.setLength(0);
try {
while (null != ((str = input.readLine())))
{
strB.append(str);
}
input.close();
} catch (IOException e) { e.printStackTrace(); }
काम करने वाली एकमात्र चीज़ की तरह लगता है। धन्यवाद। – Ales
मुझे एक ही समस्या है कृपया मदद करें। m.appendTail (एम); यह लाइन मुझे त्रुटि है। –
@ ersyn61: क्षमा करें, सही किया गया; होना चाहिए था 'मैपेंडटेल (एसबी); '। –