URL2FILE
2011-12-08 16:59 Jeff 阅读(1033) 评论(0) 编辑 收藏 举报
URL2File is a free Java application able to retrieve and save the content of a given URL to a local file.
URL2File Java console-mode application can be used by itself or within a shell script to retrieve the content of an HTML document or other file from a remote Internet server to a local file.A typical example would be to write a shell script, such as a Windows command prompt BATch file, to download multiple files.
Once the Java VM is successfully installed, copy URL2File.class to a directory of your choice and run it using the following syntax:
java URL2File
伤不起,这个不是开源的?找不到源代码.
具体JAVA code的实现可以如下:
import java.net.*; import java.io.*; class url2file{ public static void main(String args[])throws IOException { int num1; num1=1; File fi3=new File(args[1]); RandomAccessFile fi4=new RandomAccessFile(fi3,"rw"); URL urll=null; try{ urll=new URL(args[0]); DataInputStream dis; dis = new DataInputStream(urll.openStream()); while((num1=dis.read())!=-1) { fi4.write((char)num1); } fi4.close(); dis.close(); } catch(MalformedURLException e) { System.out.println(e); fi4.close(); } catch(IOException e) { System.out.println(e); fi4.close(); } } }