Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-10-2008, 04:04 PM
Member
 
Join Date: Apr 2008
Posts: 1
gsupriyarao@yahoo.com is on a distinguished road
Search TextFile
.....................................

Last edited by gsupriyarao@yahoo.com : 04-14-2008 at 03:08 AM. Reason: delete
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-10-2008, 05:59 PM
DonCash's Avatar
Moderator
 
Join Date: Aug 2007
Location: London, UK
Posts: 239
DonCash will become famous soon enoughDonCash will become famous soon enough
Do you have an example input file and desired output?

Are you happy to have it read in line by line and search that string for the word?
__________________
Did this post help you? Please
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
me!

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-10-2008, 06:19 PM
DonCash's Avatar
Moderator
 
Join Date: Aug 2007
Location: London, UK
Posts: 239
DonCash will become famous soon enoughDonCash will become famous soon enough
So once it finds a word it will show the 2 words to the left on the same line and then print out the 2 words to the right but with a new line after each of these?
__________________
Did this post help you? Please
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
me!

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 04-10-2008, 06:57 PM
Member
 
Join Date: Mar 2008
Location: Florida Johannesburg
Posts: 2
tress is on a distinguished road
Prime numbers
Does anyone know how to check if a number is prime or not
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 04-10-2008, 07:13 PM
DonCash's Avatar
Moderator
 
Join Date: Aug 2007
Location: London, UK
Posts: 239
DonCash will become famous soon enoughDonCash will become famous soon enough
Tress, why have you posted this unrelated question here? It would make more sense to start a new thread!

Please bare that in mind in the future. Anyway, use this code:

Code:
public class prime { public static void main(String[] args) { int num; int i; int factor; boolean isprime; for(num = 2; num < 20; num++) { isprime = true; factor = 0; // see if num is evenly divisible for(i=2; i <= num/2; i++) { if((num % i) == 0) { // num is evenly divisible -- not prime isprime = false; factor = i; } } if(isprime) System.out.println(num + " is prime."); else System.out.println("Largest factor of " + num + " is " + factor); } } }
__________________
Did this post help you? Please
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
me!

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 04-11-2008, 12:03 PM
DonCash's Avatar
Moderator
 
Join Date: Aug 2007
Location: London, UK
Posts: 239
DonCash will become famous soon enoughDonCash will become famous soon enough
I'm still trying to figure out how to do this. Ill post some code as soon as possible.

To start though, here is the code to read in a document line by line:

Code:
FileInputStream in = new FileInputStream("file_path/file.txt"); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; while ((strLine = br.readLine()) != null) { System.out.println(strLine); }
__________________
Did this post help you? Please
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
me!

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
reading textfile from java problem saytri New To Java 1 01-17-2008 03:13 AM
textfile with Java problems saytri New To Java 4 12-29-2007 06:16 PM
Textfile and GUI problems saytri New To Java 2 12-21-2007 05:08 PM
ECG plot in a textfile samson Java 2D 1 07-17-2007 04:53 AM
Problem with storing and retrieving from a textfile Albert Advanced Java 1 07-13-2007 04:01 PM


All times are GMT +3. The time now is 02:26 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org