package os.path;

import java.io.File;

public class Pathutil {
	public static File expanduser(String datapath) {
		return new File( datapath.replaceFirst("^~",System.getProperty("user.home")) );
	}
	
	public static void osOpen (File file) throws Exception {

		ProcessBuilder automate = new ProcessBuilder("open", file.getAbsolutePath());
		automate.redirectOutput(ProcessBuilder.Redirect.INHERIT);//output the output.
		if( 0 != automate.start().waitFor())
		{
			throw new Exception( "osOpen fail on "+file.getAbsolutePath() );
		}
		
	}
}
