TeluguWordReplacer replace telugu word in telugu file using java program.

 



నేను తెలుగు నేర్చుకుంటున్నాను
తెలుగు ఒక అందమైన భాష
తెలుగు ఒక అందమైన భాష
నేను తెలుగు నేర్చుకుంటున్నాను
మన దేశ భాషలందు తెలుగు లెస్స
---------------------------------------------------
నేను  నేర్చుకుంటున్నాను
ఒక అందమైన భాష
ఒక అందమైన భాష
నేను  నేర్చుకుంటున్నాను
మన దేశ భాషలందు  లెస్స

---------------


import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;

public class TeluguWordReplacer {
    public static void main(String[] args) {
    String inputFilePath = "C:\\Deviprasad\\input\\telugu_input.txt";
         String timestamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
         String outputFilePath = "C:\\Deviprasad\\output\\telugu_output_" + timestamp + ".txt";

        // Telugu word to be removed
        String teluguWordToRemove = "తెలుగు";

        try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(inputFilePath), "UTF-8"));
             BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFilePath), "UTF-8"))) {

            String line;
            while ((line = reader.readLine()) != null) {
                // Replace the Telugu word
                String updatedLine = line.replaceAll(teluguWordToRemove, "").trim();
                writer.write(updatedLine);
                writer.newLine();
            }

            System.out.println("File processed. Output saved to: " + outputFilePath);

        } catch (IOException e) {
            System.err.println("Error: " + e.getMessage());
        }
    }
}


Popular posts from this blog

praveen samples: idoc2edi: step by tpm configuration, with payloads

50 questoins of grok questions.

SAP CPI : camle expression in sap cpi , cm, router, filter and groovy script. format