ATOM 484 CA VAL 64 6.161 4.966 18.749 1.00 25.51 C
ATOM 485 C VAL 64 6.212 4.530 20.218 1.00 29.06 C
ATOM 486 O VAL 64 5.237 3.878 20.635 1.00 27.83 O
ATOM 487 CB VAL 64 6.574 3.757 17.904 1.00 25.10
TER 534 LYS 68
HETATM 535 ZN ZN 101 -5.889 8.020 17.081 1.00 28.92 ZN
HETATM 536 CL CL 102 -5.611 5.551 19.300 1.00 49.84 CL
HETATM 537 O HOH 103 4.601 18.810 22.009 1.00 35.24 O
HETATM 538 O HOH 104 16.348 9.882 9.050 1.00 38.49 O
HETATM 539 O HOH 105 13.273 13.044 17.973 1.00 33.83 O
END
hi
I am having the file like mentioned above.i want to print TER till END and save it another file. import java.lang.*;
import java.util.*;
import java.text.*;
import java.io.*;
public class tt {
public static void main(String[] args) throws IOException
{
File inputFile = new File("1AB4.rtf");
FileReader in = new FileReader(inputFile);
File outputFile=new File("t.rtf");
FileWriter out=new FileWriter(outputFile);
int end;
String s;
boolean stop=false;
BufferedReader br=new BufferedReader(in);
PrintWriter pw=new PrintWriter(out);
while((s=br.readLine())!=null)
{
stop = s.startsWith("END");
if (!stop)
System.out.println(s);
else
{
end=s.indexOf("TER");
s=s.substring (end,s.indexOf("END"));
System.out.println(s);
break;
}
pw.write(s);
}
in.close();
out.close();
}
}
This is not giving the output of what i am expecting.
TIA
public class tt {
public static void main(String[] args) throws IOException
{
File inputFile = new File("c:\\In.rtf");
FileReader in = new FileReader(inputFile);
File outputFile=new File("c:\\Out.rtf");
FileWriter out=new FileWriter(outputFile);
int end;
String s;
boolean stop=false;
BufferedReader br=new BufferedReader(in);
PrintWriter pw=new PrintWriter(out);
boolean busy = false;
while((s=br.readLine())!=n
{
stop = s.startsWith("END");
if (stop) {
pw.println(s);
System.out.println(s); // comment out if you don't want the END to be printed out
break;
}
else
{
busy = busy || (s.indexOf("TER")!=-1);
if (busy) {
System.out.println(s);
pw.println(s);
}
}
}
in.close();
out.close();
}
}