Hi I am using below code to read the file just after update the same. The file i.e. FileA.txt
stored in resource folder
public void dataSetup() throws SQLException, IOException {
InputStream input = TestHelper.class.getClassLoader().getResourceAsStream("FileA.txt");
Scanner s = new Scanner(input).useDelimiter("\\A");
String result = s.hasNext() ? s.next() : "";
result = result.replace("oldtext", "newText");
FileOutputStream fileOut = new FileOutputStream("FileA.txt",false);
fileOut.write(result.getBytes());
fileOut.flush();
fileOut.close();
readData("FileA.txt");
}
public void readData(String myFile) throws IOException, SQLException {
InputStream inputSql = TestHelper.class.getClassLoader().getResourceAsStream(myFile);
String runSql = new String(inputSql.readAllBytes());
}
With above code I can see updated string in result
, but after check the runSql
string still the original string (before update).