944,144 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1204
  • Java RSS
Sep 15th, 2007
0

Removing paragraph

Expand Post »
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
Last edited by abar_sow; Sep 15th, 2007 at 5:42 pm.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
abar_sow is offline Offline
36 posts
since Jul 2007
Sep 15th, 2007
0

Re: Removing paragraph

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)?
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 874
Code tags enforcer
peter_budo is offline Offline
6,659 posts
since Dec 2004
Sep 16th, 2007
0

Re: Removing paragraph

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
Last edited by abar_sow; Sep 16th, 2007 at 2:12 am.
Reputation Points: 10
Solved Threads: 0
Light Poster
abar_sow is offline Offline
36 posts
since Jul 2007
Sep 18th, 2007
0

Re: Removing paragraph

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...
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 839
Posting Genius
Ezzaral is offline Offline
6,761 posts
since May 2007
Sep 18th, 2007
0

Re: Removing paragraph

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
Last edited by abar_sow; Sep 18th, 2007 at 2:48 pm.
Reputation Points: 10
Solved Threads: 0
Light Poster
abar_sow is offline Offline
36 posts
since Jul 2007
Sep 19th, 2007
0

Re: Removing paragraph

Locate the error plssssss

Java Syntax (Toggle Plain Text)
  1. import java.io.*;
  2. import java.io.BufferedInputStream;
  3. import java.io.BufferedOutputStream;
  4. import java.io.FileInputStream;
  5. import java.io.FileOutputStream;
  6. import java.io.IOException;
  7. import java.io.FilenameFilter;
  8. import java.io.File;
  9. import java.lang.*;
  10.  
  11. class FileWriteDemo
  12. {
  13. public static void main(String args[])throws IOException
  14. {
  15. FileReader fr = new FileReader("file3.txt");
  16. BufferedReader br = new BufferedReader(fr);
  17. String s;
  18. StringBuffer sr =new StringBuffer(br);
  19. while(sr=br.readLine())!= null)
  20. {
  21.  
  22. if(sr=="hi")
  23. {
  24. sr.delete(0,100);
  25. }
  26. }
  27.  
  28.  
  29. FileWriter f1= new FileWriter("file4.txt");
  30. String str1=sr.toString();
  31. f1.write(str1);
  32. f1.close();
  33. }
  34. }

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
Reputation Points: 10
Solved Threads: 0
Light Poster
abar_sow is offline Offline
36 posts
since Jul 2007
Sep 19th, 2007
0

Re: Removing paragraph

You are missing an open paren "(".
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 839
Posting Genius
Ezzaral is offline Offline
6,761 posts
since May 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: debugging JNI application
Next Thread in Java Forum Timeline: Arrays and ArrayList





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC