public void saveNewParam(){ String wahl = combo.getSelectedItem().toString(); String key = tf_Key.getText(); String abnr = tf_AbNr.getText(); String erfk = tf_ErfKennz.getText(); String grpnr = tf_GrpNr.getText(); String sznr = tf_SZNr.getText(); String dat = tf_Dat.getText(); String sfnr = tf_SFNr.getText(); String res = tf_Res.getText(); String vk = tf_VKennz.getText(); String dateiAlt = ""; String dateiNeu = ""; String zeileAlt = ""; String zeileNeu = (wahl + " " + key + " " + abnr + " " + erfk + " " + grpnr + " " + sznr + " " + dat + " " + sfnr + " " + res + " " + vk); try { BufferedReader br = new BufferedReader (new FileReader ("sy.prn")); BufferedWriter bw = new BufferedWriter (new FileWriter ("sy.prn")); while((dateiAlt = br.readLine()) != null) { StringBuffer sb = new StringBuffer(dateiAlt); dateiNeu = sb.toString(); String name = dateiAlt.substring(0,2); if (wahl.equals(name)) { zeileAlt = dateiAlt.substring(0,40); dateiNeu = strReplace(dateiNeu, zeileAlt, zeileNeu); bw.write(dateiNeu); bw.newLine(); } else { bw.write(dateiNeu); bw.newLine(); } } br.close(); bw.close(); } catch (Exception e) { System.out.println(e); }}public static String strReplace(String datei, String alt, String neu){ String s1; String s2; int alen = alt.length(); int nlen = neu.length(); int index = datei.indexOf(alt); try { while (index != -1) { s1 = datei.substring(0, index); s2 = datei.substring(index + alen); datei = s1 + neu + s2; index = datei.indexOf(alt,index+nlen); } return (datei); } catch (Exception e) { return(datei); }}