class="java" name="code"> public static void main(String[] args) throws Exception { InputStream in=null; try { URL url=new URL("http://yanbh.iteye.com/admin/blogs/1987350"); in=url.openStream(); byte buffer[]=new byte[100000]; in.read(buffer, 0, buffer.length); System.out.println(new String(buffer)); } catch (MalformedURLException e) { e.printStackTrace(); } } public static void main(String[] args) throws IOException { //生成文件目录 File dir1=new File("D:\\dir1"); if(!dir1.exists()) dir1.mkdir(); File dir2=new File(dir1,"dir2"); if(!dir2.exists()) dir2.mkdir(); File dir4=new File(dir1,"dir3\\dir4"); if(!dir4.exists()) dir4.mkdirs(); File file=new File(dir2,"2.txt"); if(!file.exists()) file.createNewFile(); //解析文件目录 File dir=new File("D:\\dir1"); ListDir(dir); } public static void ListDir(File dir){ File[] lists=dir.listFiles(); String info="目录:"+dir.getName()+"("; for(int i=0;i<lists.length;i++){ info+=lists[i].getName()+" "; } info+=")"; System.out.println(info); for(int i=0;i<lists.length;i++){ File f=lists[i]; if(f.isFile()){ System.out.println("文件:"+f.getName()+" canRead:"+f.canRead()+" lsatModified:"+new Date(f.lastModified())); }else{ ListDir(f); } } }