import java.io.*; import java.util.*; class Program { private static String fajlOlvas(String path) { File file = new File(path); Scanner olvaso = null; StringBuilder strb = new StringBuilder((int)file.length()); try { olvaso = new Scanner(file); } catch(IOException e) { e.printStackTrace(); } String sorTores = System.getProperty("line.separator"); try { while(olvaso.hasNextLine()) strb.append(olvaso.nextLine() + sorTores); return strb.toString(); } finally { olvaso.close(); } } public static void main(String[] args) { String str = fajlOlvas("adat.txt"); System.out.println(str.replace("m", "g")); } }