Can we pass a Url path and a file name to FileOutputStream in java -
sir new in java want write file on url path there possible way write file on url path give me tips
no can not pass url path , filename both parameter fileoutputstream.
however can write a file reading specified url using below code:
try{ url url = new url("http://docs.oracle.com/javase/7/docs/api/java/io/fileoutputstream.html"); string path = "d://stackoverflow/"; inputstream ins = url.openstream(); outputstream ous = new fileoutputstream(path); final byte[] b = new byte[2048]; int length; while ((length = ins.read(b)) != -1) { ous.write(b, 0, length); } ins.close(); ous.close(); } catch(exception e){ e.printstacktrace(); } and please explain trying achieve passing url , filename fileoutputstream?
Comments
Post a Comment