class FileIDFactory {

	public static String createFileID()  {
		try {
			// Ensure time uniqueness within process
			Thread.sleep(2);
		} catch (InterruptedException e1) {
		}
		int uniquePort = 0;
		byte[] addrBytes = null;
		ServerSocket serverSocket = null;
		try {
			StringBuffer buf = new StringBuffer();
			serverSocket = ServerSocketFactory.getDefault().createServerSocket();
			serverSocket.bind(null);
			uniquePort = serverSocket.getLocalPort();
			addrBytes = InetAddress.getLocalHost().getAddress();
			for (int i = 0; i < 4; i++) {
				int b = addrBytes[i] & 0xff;
				buf.append(Integer.toHexString(b));
			}
			buf.append(Integer.toHexString(uniquePort));
			buf.append(System.nanoTime());
			return buf.toString();
		} catch (IOException e) {
		} finally {
			if (serverSocket != null) {
				try {
					serverSocket.close();
				} catch (IOException e) {
				}
			}
		}
		
		// We do not have a network interface :( 
		// TODO: this case could use improvement - possible exposure is use of shared project in an off-line mode
		return Long.toHexString(System.nanoTime());
	}

	private  FileIDFactory();

}