M
Mady
Доброго времени суток.
Проблема следующая,
Я пытаюсь пройти веб авторизацию и скачать, файл. проблема следующая если файл содержит кириллицу то url получается кодированный. и когда отрабатывает код файл не скачивания, а с латиницей все нормально.
пример кода.
HttpClient client = new HttpClient();
client.getParams().setParameter("username", "admin");
client.getParams().setParameter("password", "123456789");
HostConfiguration host = client.getHostConfiguration();
host.setHost(new URI("http://localhost:8082", true));
String fileString = "/test.nsf/7f65461bc464365e462578bf00137d8e/3cdd090b4a5588d6462578bf0047fbba/$FILE/%D0%94%D0%B0%D0%BD%D0%BD%D1%8B%D0%B5.doc";
//String fileString = "/test.nsf/7f65461bc464365e462578bf00137d8e/459f167f3c0ab7d7462578bf004913ac/$FILE/DA.doc";
GetMethod method = new GetMethod("http://192.168.89.109:8082/names.nsf?login&username=admin&password=123456789&RedirectTo="+fileString);
client.executeMethod(host, method);
byte[] bs = method.getResponseBody();
if (bs.length==0) return;
System.out.println(bs.length);
File file = new File("D:\\test.doc");
OutputStream out = new FileOutputStream(file);
out.write(bs);
out.close();
Проблема следующая,
Я пытаюсь пройти веб авторизацию и скачать, файл. проблема следующая если файл содержит кириллицу то url получается кодированный. и когда отрабатывает код файл не скачивания, а с латиницей все нормально.
пример кода.
HttpClient client = new HttpClient();
client.getParams().setParameter("username", "admin");
client.getParams().setParameter("password", "123456789");
HostConfiguration host = client.getHostConfiguration();
host.setHost(new URI("http://localhost:8082", true));
String fileString = "/test.nsf/7f65461bc464365e462578bf00137d8e/3cdd090b4a5588d6462578bf0047fbba/$FILE/%D0%94%D0%B0%D0%BD%D0%BD%D1%8B%D0%B5.doc";
//String fileString = "/test.nsf/7f65461bc464365e462578bf00137d8e/459f167f3c0ab7d7462578bf004913ac/$FILE/DA.doc";
GetMethod method = new GetMethod("http://192.168.89.109:8082/names.nsf?login&username=admin&password=123456789&RedirectTo="+fileString);
client.executeMethod(host, method);
byte[] bs = method.getResponseBody();
if (bs.length==0) return;
System.out.println(bs.length);
File file = new File("D:\\test.doc");
OutputStream out = new FileOutputStream(file);
out.write(bs);
out.close();