2014-11-08 2 views
0

물결표가있는 사이트에 일부 데이터를 게시 할 때 이상한 문제가 있습니다. 어떻게 Android에서 해결할 수 있습니까? http://host-site.com/~username/form.phphttpurlconnection을 사용할 때 물결표가있는 사이트의 FileNotFoundException

가 여기에 내 코드입니다 :

url = new URL(hostSiteString); 
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); 
urlConnection.setRequestProperty("Host", "myHost"); 
urlConnection.setRequestProperty("User-Agent", "Mozilla/4.0"); 
urlConnection.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); 
urlConnection.setRequestProperty("Accept-Language", "en-US;q=0.7,en;q=0.3"); 
urlConnection.setRequestProperty("Accept-Encoding", "gzip, deflate"); 
urlConnection.setRequestProperty("Connection", "keep-alive"); 
urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); 
urlConnection.setDoOutput(true); 

BufferedOutputStream bos = new BufferedOutputStream(urlConnection.getOutputStream()); 
bos.write(readyToken.getBytes(), 0, readyToken.length()); 
bos.flush(); 
bos.close(); 

답변

0

찾을 솔루션, 내 URL을 디코딩했다

는 예를 들어, 내 사이트입니다.

String decode = URLDecoder.decode(hostSiteString); 
url = new URL(decode); 
+0

이상합니다. 나는 당신이 당신의 URL을 인코딩해야한다고 생각했을 것입니다. – greenapps