string manipulations
Hie dear frenz,
Im a beginner here, I would like your help on how to to string manipulations. I have done aprogram that reads a text lines from a file and write it out to another text file. But, at the same time, I need to display the text file line by line and store it in the string, and manipulate it. he manipulations i emant is like adding some semiclons after soem characters and write out to a new file. I dunt understand how to store the string here adn how to manipulate it from the stored place. Plz help me here. Thanks in advance. Here is the code of the program for ur reference.....may GOD bless you...
mport java.io.*;
import java.util.*;
class ReadData1Test
{
public static void main(String args[]) //main declaration
{
ReadData1Test r = new ReadData1Test();//constructor
r.readmyfile();
}
void readmyfile(){
// String line = null;
// int recCount = 0;
try{
FileReader fr= new FileReader("aliran.txt");// the FileReader is a subclass of InputStreamReader that is useful if you want to read text from a data file.
BufferedReader br = new BufferedReader(fr);//use Bufferreader instead of datainputstream as it is depreciated
PrintWriter pw = new PrintWriter ("newaliran.txt");// to print the contents of read file to a new file
//line = new String();
// while ((line= br.readLine()) != null) {
// recCount++;
//System.out.println(recCount + ": " + line);
String line;
line = br.readLine();
br.close();
pw.close();
pw.println(line);
System.out.println("The first line in the text file is: " + line);//print out the text in the file
}
//
catch (IOException e) {
// catch possible io errors from readLine()
System.out.println("Problem finding file!");
}
}

