For my proje i want to remove a unwanted paragraph in a text file. For example my text file may have acknowledgment in between sum useful data so i want to remove the acknowledgment paragraph fully...can anyone tel how to do tat

Recommended Answers

All 6 Replies

Removing is the easy part you have to think about how you gone search/locate this unwanted part of text. What sort of criteria you will use? How you will handle your text, where you will get it from (user/file)?

Am taking Text files from the folder it may have sum 30 files.Consider the papers like ieee if am having acknowledgement in between abstract and sum other topic i want to remove the acknowledgement In my previous thread i removed a line but considering paragraph, I dont know where to stop ..Here we cant expect all text files topic in this order in tat case how it comes.For example

Abstract
Test managers often need to make an initial estimate of the number of people

Acknowledgement
Some of the material in this paper was developed by the participants

Introduction
Past tester to developer ratios are often useful for making rough estimates of required test

You'll have to read from one file and write what you want into another. As you scan your input, when you find line.startsWith("Acknowledgement") then keep reading lines but don't write any data until you get to the line.startsWith("Introduction").

I hope you aren't stripping copyrighted material of all copyright and acknowledegment info and presenting it for download though...

No its for my project as i said earlier, it may not contain useful information ....so I can do tat for only one file at a time.Or is there Options for doing multiple files

Locate the error plssssss

import java.io.*;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.FilenameFilter;
import java.io.File;
import java.lang.*;

class FileWriteDemo
{
  public static void main(String args[])throws IOException
  {
	FileReader fr = new FileReader("file3.txt");
	BufferedReader br = new BufferedReader(fr);
	String s;
	StringBuffer sr =new StringBuffer(br);
	while(sr=br.readLine())!= null)
	{
          
		if(sr=="hi")
                 {
		   sr.delete(0,100);
		 }
       } 
	
 
   FileWriter f1= new FileWriter("file4.txt");
   String str1=sr.toString();
   f1.write(str1);
   f1.close();
  }
}

error:
D:\program files\Java\jdk1.5.0\bin>javac FileWriteDemo.java
FileWriteDemo.java:19: illegal start of expression
while(sr=br.readLine())!= null)
^
1 error

You are missing an open paren "(".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.