ファイル名にumlautが含まれる「 http://somesimpledomain.com/some/path/überfile.txt 」のようなURLを取得しようとしていますが、java.io.FileNotFoundExceptionが発生します。私のURLはutf8ですが、リモートサーバーのファイル名はlatin1でエンコードされていると思われます。しかし、URLのエンコーディングを変更しようとしても成功せず、さらにデバッグする方法がわかりません。助けてください!
コードは次のとおりです。
HttpURLConnection conn = null;
try {
conn = (HttpURLConnection) new URL(uri).openConnection();
conn.setRequestMethod("GET");
} catch (MalformedURLException ex) {}
} catch (IOException ex){}
// Filter headers
int i=1;
String hKey;
while ((hKey = conn.getHeaderFieldKey(i)) != null) {
conn.getHeaderField(i);
i++;
}
// Open the file and output streams
InputStream in = null;
OutputStream out = null;
try {
in = conn.getInputStream();
} catch (IOException ex) {
ex.printStackTrace();
}
try {
out = response.getOutputStream();
} catch (IOException ex) {
}
よろしく、ヘンドリック