Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; public class Main { private static ArrayList<String> mounts = new ArrayList<String>(); private static ArrayList<String> mountsPR = new ArrayList<String>(); private static ArrayList<String> aliases = new ArrayList<String>(); private static ArrayList<String> aliasesPR = new ArrayList<String>(); public static final String invertMountPrefix(final String fileName) { for (int i = 0, n = Math.min(aliases.size(), mounts.size()); i < n; i++) { final String alias = aliases.get(i); final String mount = mounts.get(i); if (fileName.equals(alias)) { return mount; } if (fileName.equals(mount)) { return alias; } } for (int i = 0, n = Math.min(aliasesPR.size(), mountsPR.size()); i < n; i++) { final String alias = aliasesPR.get(i); final String mount = mountsPR.get(i); if (fileName.startsWith(alias)) { return mount + fileName.substring(alias.length()); } if (fileName.startsWith(mount)) { return alias + fileName.substring(mount.length()); } } return null; } }