I have a cron job schedule in my Ubuntu or Runnable JAR running.
I have received an exception on my string URL but on my Windows development it is OK. it could not resolve the correct string url
please check below
java.io.FileNotFoundException: http://www.carlolotti.com/enoteca-vini-valdostani/chardonnay-elevé-en-fut-de-chene-anselmet-2007-6s0jwecq.asp
here is the source code:
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;
I'm suspecting the Language of my Ubuntu on my Locale LANG=en_GB.UTF-8
Do I need to change this to en_US.UTF-8
? I'm not really sure about it but this is my 1st investigation.
您必须用é
替换URL中的é
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.