public List<Integer> encodeData(String data) {
		wbEncoding = new HashMap<String, Integer>();

		StringBuffer sb = new StringBuffer(data);

		List<Integer> encoded = new LinkedList<Integer>();

		int nextIndex = 256;

		while (sb.length() > 0) {
			int i = 1;

			// char not available
			if (wbEncoding.get(sb.substring(0, i)) == null) {
				// ascii char?
				if (sb.substring(0, i).toCharArray()[0] < 256) {
					wbEncoding.put(sb.substring(0, i), (int) sb.substring(0, i)
							.toCharArray()[0]);
				}
				encoded.add(wbEncoding.get(sb.substring(0, i)));

				if (sb.length() > i) {
					wbEncoding.put(sb.substring(0, i + 1), nextIndex);
					nextIndex++;
				}

				sb.delete(0, i);
			} else {
				if (sb.length() < 5) {
					// System.out.println(sb);
				}
				while (wbEncoding.get(sb.substring(0, i)) != null) {
					i++;
					if (i >= sb.length()) {
						break;
					}
				}
				if (wbEncoding.get(sb.substring(0, i)) != null) {
					encoded.add(wbEncoding.get(sb.substring(0, i)));
					// remove scanned
					sb.delete(0, i);
				} else {
					encoded.add(wbEncoding.get(sb.substring(0, i - 1)));

					// add new dictionary entry
					wbEncoding.put(sb.substring(0, i), nextIndex);
					nextIndex++;

					// remove scanned
					sb.delete(0, i - 1);
				}

			}
		}

		for (String s : wbEncoding.keySet()) {
			System.out.println(s + ":" + wbEncoding.get(s));
		}

		System.out.println("lzw encoding finished");
		System.out.println("highest index: " + nextIndex);
		return encoded;
	}