private static void printAllPermutations2(char[] str) {
		Set<String> sofar = new HashSet<String>();
		sofar.add("" + str[0]);
		for (int i = 1; i < str.length; i++) {
			Set<String> toAdd = new HashSet<String>();
			for (String s : sofar) {
				for (int k = 0; k <= s.length(); k++) {
					toAdd.add(s.substring(0, k) + str[i] + s.substring(k));
				}
			}
			sofar=toAdd;
		}
		for (String s : sofar) {
			System.out.println(s);
		}
	}