public void urlWriter(int y) throws IOException
{
File file = new File("C:\\DRIVE\\datas.txt");
FileWriter fw = new FileWriter(file);
BufferedReader dummyReader = new BufferedReader(new FileReader(file));
BufferedWriter latestSource = new BufferedWriter(fw);
//dummy string to read line by line
String dooms =null;
//loop for reading line by line
for(i=0;i<y;i++)
{
while ((dooms=dummyReader.readLine())!=null)
{
//y line
latestSource.write(CommonData.entered_direct);
latestSource.newLine();
//y+1 line
latestSource.write(CommonData.entered_cellar);
latestSource.newLine();
//y+2 line
latestSource.write(CommonData.entered_tele);
latestSource.close();
}
}
Tried to read line by line and then write at the specific locations. But the same issue exists.. Can some one help me out...????
Scenario : if y value is passed as '4', the 4th,5th,6th line in the text file should be replaced with new data.Highly appreciable if some one helps me. Thanks in advance!!
Issue faced :All the data is getting written at the bottom of the text file instead of sticking to the specified line number