Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
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 07-05-2007, 08:58 AM
Senior Member
 
Join Date: Jun 2007
Posts: 111
Eric is on a distinguished road
Reading FileInput data
Hi all, let's say we have a text file named "data1.txt" which contains 5 lines of random letters with no spaces.

I want to create a java program that reads the data in data1.txt and prints the length (number of letters on one line), the first 5 letters in data1.txt, and truncate those 5 letters to the first 3 letters and print those 3 letters on the output screen.

Basically, I just want a simple program that reads the data in a txt data file (with "File newone = new File("data1.txt");" ?) and manipulates what's read.

Thanks
Eric
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-05-2007, 08:59 AM
Member
 
Join Date: Jun 2007
Posts: 92
Daniel is on a distinguished road
The java tutorials has a great little piece of File IO that includes how to read in a file and how to scan each element inside of that file.

Scanning and Reading a File


After learning how to get each element of a file it should be rather easy to figure out how to just print out the first three.

Greetings
Daniel
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 data from Micrsoft excel and writing to notepad abhishek.jain New To Java 2 06-18-2008 02:24 PM
Reading data form Excel using Jdbc (example) Java Tip Java Tips 0 02-13-2008 01:23 PM
Reading Binary File and Changing data janakiram.attuluri Advanced Java 1 12-21-2007 12:10 PM
Reading Data from a file ramachandran New To Java 2 10-24-2007 09:22 AM
Reading file data that contains no spaces jdepue Advanced Java 1 08-01-2007 06:58 AM


All times are GMT +3. The time now is 03:55 PM.


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