Hi gurus,
I have this function to read some file from a url. It works good exept at one case... If the URL that I'm try accessing have login authenthication this stop's at line s = c.openInputStream();.Code:private StringBuffer LoadFile(String url, String fileName) throws IOException { StreamConnection c = null; InputStream s = null; StringBuffer sb = new StringBuffer(); String err=null; try { c = (StreamConnection)Connector.open(url + fileName); try{ s = c.openInputStream(); String[] strAux=null; int ch, i=0; while((ch = s.read()) != -1) { sb.append((char) ch); } String strSb=null; strSb=sb.toString(); }catch (ConnectionNotFoundException ce){ err = ce.getMessage(); sb = null; Alert alertM = new Alert("Info: (LoadFile)", err, null, AlertType.INFO); Display.getDisplay(this).setCurrent(alertM); }catch (IOException e){ err = e.getMessage(); sb = null; Alert alertM = new Alert("Info: (LoadFile)", err, null, AlertType.INFO); Display.getDisplay(this).setCurrent(alertM); } }catch (Exception ce){ err = ce.getMessage(); sb = null; } finally { if(s != null) { s.close(); } if(c != null) { c.close(); } return sb; } }
The thing is that when I try to access to this file in the same URL from normally process by phone (not in my app) this request user and password. At my app this do not happen. Can anyone explain me why and what can I do to automatically request user/password only when it's necessary?

Reply With Quote

