J#-网络下载

ylbtech_java

try
        {
            //url网络资源地址
            URL url = new URL("http://localhost/appserv/flag-english.png");
            //打开url连接
            URLConnection conn = url.openConnection();
            
            InputStream in = conn.getInputStream();//输入字节流
            FileOutputStream out = new FileOutputStream(new File("F:/a.png"));
            byte b[] = new byte[1024];
            while(in.read(b) != -1)
            {
                out.write(b);
            }
            out.close();
            in.close();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }

 

posted on 2014-07-06 23:41  ylbtech  阅读(283)  评论(0编辑  收藏  举报