Results 1 to 2 of 2
  1. #1
    Eric is offline Senior Member
    Join Date
    Jun 2007
    Posts
    111
    Rep Power
    0

    Default 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

  2. #2
    Daniel is offline Member
    Join Date
    Jun 2007
    Posts
    91
    Rep Power
    0

    Default

    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:o

Similar Threads

  1. Reading data from Micrsoft excel and writing to notepad
    By abhishek.jain in forum New To Java
    Replies: 4
    Last Post: 01-29-2009, 09:12 AM
  2. Reading data form Excel using Jdbc (example)
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-13-2008, 12:23 PM
  3. Reading Binary File and Changing data
    By janakiram.attuluri in forum Advanced Java
    Replies: 1
    Last Post: 12-21-2007, 11:10 AM
  4. Reading Data from a file
    By ramachandran in forum New To Java
    Replies: 2
    Last Post: 10-24-2007, 08:22 AM
  5. Reading file data that contains no spaces
    By jdepue in forum Advanced Java
    Replies: 1
    Last Post: 08-01-2007, 05:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •