Pattern pattern = Pattern.compile("([^:]+):([^\n\r]+)"); Matcher matcher = pattern.matcher (fileString); //System.out.println(fileString); System.out.println("Matches: " + matcher.matches()); while (matcher.find()) { String key = matcher.group(1).trim(); String value = matcher.group(2).trim(); System.out.println("'" + key + "': " + value); configuration.put(key, value); } /* output: ( NO order size ?!?!?%@?@?%%) 'order price': 570 'store price': 600 'lost price': 4350 'initial amount': 28 'timelength': 24 'epsilon': 0.01 */ /* fileString: table1 (6,8);(7.11);(8,17);(9,33);(10,25);(11,3);(12,3); table2 (1,0.44);(2,0.33);(3,0.16);(4,0.07); order size: 10 order price: 570 store price: 600 lost price: 4350 initial amount: 28 timelength: 24 epsilon: 0.01 */