android - Java IO File not found exception -


i developed servlet , i'm trying access through android application. here important part async class. 'params[0]' url passed in parameter

url url; bufferedreader reader = null; string s = ""; try {     url = new url(params[0]);     urlconnection con = url.openconnection();       reader = new bufferedreader(new inputstreamreader(       con.getinputstream()));     string line = "";     while ((line = reader.readline()) != null) {         s = s + line;     } } catch (malformedurlexception e) {     e.printstacktrace();             } catch (ioexception e) {                 e.printstacktrace();             } catch (exception e) {                 e.printstacktrace();             }  

this works of times. sometimes, java.io.filenotfoundexception when take same url , try in browser works, application doesn't work no matter how many times try it. here logcat:

05-14 19:35:51.852: w/system.err(767): java.io.filenotfoundexception: http://192.168.10.105:8080/carpoolserver/editprofileservlet?name=anna&yob=1977&gender=female&major=architecture&uni=n/a&occupation=software development&hobby1=basketball&hobby2=reading&hobby3=football&email=jad_naoum%40hotmail.com&phone=70202018&from11=beirut&from12=beirut&from13=mousseitbeh&to11=beirut&to12=beirut&to13=mazraa&days1=sat&time_from1=3:21am&time_to1=4:21pm&car=true 05-14 19:35:51.852: w/system.err(767):  @ libcore.net.http.httpurlconnectionimpl.getinputstream(httpurlconnectionimpl.java:186) 05-14 19:35:51.852: w/system.err(767):  @ com.jad.carpooling.editprofile$async.doinbackground(editprofile.java:416) 05-14 19:35:51.862: w/system.err(767):  @ com.jad.carpooling.editprofile$async.doinbackground(editprofile.java:1) 05-14 19:35:51.862: w/system.err(767):  @ android.os.asynctask$2.call(asynctask.java:287) 05-14 19:35:51.862: w/system.err(767):  @ java.util.concurrent.futuretask.run(futuretask.java:234) 05-14 19:35:51.862: w/system.err(767):  @ android.os.asynctask$serialexecutor$1.run(asynctask.java:230) 05-14 19:35:51.862: w/system.err(767):  @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1080) 05-14 19:35:51.872: w/system.err(767):  @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:573) 05-14 19:35:51.872: w/system.err(767):  @ java.lang.thread.run(thread.java:856) 

any ideas?



i figured out. seems didn't encode url properly. there space in url. when encoded it, worked. help

you have replace spaces %20 here code replacing space.

strurl = strurl.replace(" ", "%20"); 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -