package alx.p41_file;

import java.io.File;
import java.io.IOException;

public class Absolute {

	public static void main(String[] args) {

		String path;
		if(args.length > 0)
			path = args[0];
		else path = "/katalog/../nowy.txt";
		String path2 = "./a/b/c.zip";
		
		File file = new File(path);
		File file2 = new File(path2);
		System.out.println("separatory: " + File.pathSeparator + " " +File.separator);

		System.out.println("Argument : "+path);
		System.out.println("Argument : "+path2);
		System.out.println("Name     : "+file.getName());
		System.out.println("Name     : "+file2.getName());
		System.out.println("Absolute : "+file.getAbsolutePath());
		System.out.println("Absolute : "+file2.getAbsolutePath());
		
		String[] czlony = file.getName().split("\\.");
		if(czlony.length >= 2)
			System.out.println(czlony[czlony.length-1]);
		
		try {
			System.out.println("Canonical: "+file.getCanonicalPath());
			System.out.println("Canonical: "+file2.getCanonicalPath());
		} catch(IOException e) {
			e.printStackTrace();
		}
	}
}
