0
我在運行Ubuntu或Runnable JAR時有一個cron作業計劃。URL未在ubuntu中解析14.04
我在我的字符串URL上收到了一個異常,但是在我的Windows開發中卻沒有問題。它不能解析正確的string url
請檢查下面
java.io.FileNotFoundException: http://www.carlolotti.com/enoteca-vini-valdostani/chardonnay-elevé-en-fut-de-chene-anselmet-2007-6s0jwecq.asp
這裏是源代碼:
HttpURLConnection conn;
URL obj = new URL(url);
conn = (HttpURLConnection) obj.openConnection();
// default is GET
conn.setRequestMethod("GET");
conn.setUseCaches(true);
// act like a browser
conn.setRequestProperty("User-Agent", USER_AGENT);
conn.setRequestProperty("Accept",
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
int responseCode = conn.getResponseCode();
if(debug)
System.out.println("\nSending 'GET' request to URL : " + url);
if(debug)
System.out.println("Response Code : " + responseCode);
try{
BufferedReader in =
new BufferedReader(new InputStreamReader(conn.getInputStream() , "UTF-8"));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
//inputLine=StringEscapeUtils.escapeHtml3(inputLine);
//if(inputLine.contains("Albari"))
// t=1;
response.append(inputLine);
if(csv)
response.append(lineRet);
}
in.close();
return response;
}catch(Exception e){
e.printStackTrace();
}
return null;
我懷疑我的Ubuntu的語言對我的語言環境LANG=en_GB.UTF-8
我需要這種改變en_US.UTF-8
?我不太確定,但這是我第一次調查。
它應該被解釋爲UTF-8時,它看起來像被解釋爲ISO-8859-1。但是,如果沒有源代碼和關於字符串來自何處的解釋,將很難爲您提供幫助。 – RealSkeptic
你是對的。我添加了我的源代碼。 –
而在這個來源的錯誤發生在哪裏?什麼是URL字符串的來源? – RealSkeptic