Sign up to create your own snipts, or login.

Public snipts » rohini_hino's snipts » add/del a directory and a file

posted on Dec 21, 2009 at 10:38 a.m. EST in 
  • import java.io.*;
    class MyClass1
    	{
    	
    	public static void main(String[] args) throws IOException
    		{
    		String currentDirectory="/java";
    		String s[];
    		File d=new File("new folder");
    		d.mkdir();
    		
    		
    		
            	File f1 = new File("f1.txt");
        		File f2=new File("f2.txt");
            	
           		f1.createNewFile();
    		f1.renameTo(f2);
            	
    		File dir=new File(currentDirectory);
    		s=dir.list();
        		for(int i=0;i<s.length;i++)
    			System.out.println(s[i]+"\n");
    			
            	d.delete();	
    		}
    	
    	}
    

    copy | embed

0 Comments

Sign up, or login to leave a comment.