package org.mynonglam.entitys;

import java.io.File;

import com.oreilly.servlet.multipart.FileRenamePolicy;

public class RandomNameUploading implements FileRenamePolicy{
	private String name;
	private String ext;
	@Override
	public File rename(File arg0) {
		// TODO Auto-generated method stub
		name = Long.toHexString(Double.doubleToLongBits(Math.random()));
		return new File(arg0.getParentFile(), (name + ext));
	}
	
	public String getName() {
		return this.name + this.ext;
	}

	public void setExt(String ext) {
		int index = ext.lastIndexOf(".");
		this.ext = ext.substring(index, ext.length());
	}
	
}
