package files_tools;

import java.io.File;

//import java.io.File;

public class files 
{


	public static void main(String[] args) 
	{     
		  String ext = getFileExtensionName(new File("a.t"));
		  System.out.println(ext);
        
      //  File file = new File("/Users/al");
        
      /*  if (file.getName().toLowerCase().endsWith(file))
        {
            System.out.println(ext);

        }*/
        
    }
	
	 public static String getFileExtensionName(File f) 
	 {
		 
		 	String result = "";
		 
		 	if(f.getName().contains("."))
		 	{	
		 
		 		if (f.getName().indexOf(".") == -1)
		 		{
		 			result = "vide";
		 		} 
		 		else 
		 		{
		 			result = f.getName().substring(f.getName().length() - 3, f.getName().length());
		 		}
		 	}

		 	else
		 	{
		 		result = "error";
		 	}
		 	
		 	return(result);
	}
	 
	public void create()
	{
		try
		{
			File file = new File("c:\\test\\test.txt");
			file.createNewFile();
		}
		catch (Exception e)
		{
			
		}
		
	}
	
	public void create_dir()
	{
		File file = new File("c:\\test\\");
	    file.mkdir();
	}
	 
	public void rename()
	{
		 	File file = new File("c:\\text.txt");
		    file.renameTo(new File("c:\\text.txt.bak"));
	}
	
	public void delete()
	{
		 	File file = new File("c:\\test\\test.txt");
		    boolean success = file.delete();
		    System.out.println(success);
	}
	
}
