Code
Akshita Akki ReddyHi This is a dummy text
To reach the line where the actual problem is
REPLACE==ZZZZ== by ==WORK==
Hi1 ZZZZ at TCS
The ZZZZING HOURS are from 9AM TO 6PM
REPLACE OFF
This marks the replace off so do not replace text after this
testing ZZZZ
it should still stay ZZZZ
Finding Solution
import java.io.File;
import java.io.IOException;
import java.util.*;
class base{
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(new File("file.txt"));
sc.useDelimiter("\n");
while (sc.hasNext()) {
String s = sc.next();
if (s.trim().isEmpty()) {
continue;
}
String ip = s;
System.out.println(ip);
// String text= new String(ip);
// String[] sentences = text.split("\\.");
// System.out.println(Arrays.toString(sentences));
// String[] sen = Arrays.toString(sentences);
// String op = ip.replace("ZZZZ", "WORK");
}
}
}
Created with Telegraph X Pro