DivideThousand implements AccessStrategy { @Override public String find(long id) { Stack<Long> stack = new Stack<Long>(); for (; id * base >= base; id = id / base) { stack.push(id); } StringBuilder builder = new StringBuilder(); for (; !stack.isEmpty();) { builder.append(stack.pop()).append(File.separator); } builder.setLength(builder.length() - 1); return builder.toString(); } DivideThousand();  DivideThousand(int base); @Override String find(long id); void setBase(int base);  }
@Test public void find() { AccessStrategy strategy = new DivideThousand(); String where = strategy.find(1234567890); assertEquals("1\\1234\\1234567\\1234567890".replace("\\", File.separator), where); where = strategy.find(123456789); assertEquals("123\\123456\\123456789".replace("\\", File.separator), where); }