File Extension Changer program

Discussion in 'Java' started by Andrew Tegala, Aug 13, 2003.

  1. Dear All,

    I would like help with creation of a few Java Programs.

    Mainly, a program to change the extension of a file, from .txt to
    ..lst. It needs to take teh filename as a command line argument and
    outputs a 'list' file.

    For example the text file, "test.txt"
    This is a
    small text file
    The end.

    Would be produce a file, "test.lst"

    1 This is a
    2 small text file
    3 The end.

    Another program I need help with is to take student details from a
    text file and output the e-mail address.

    Using the String, StringTokenizer and StringBuffer classes.

    The details are in the form of "surname:firstname:id"

    output should be

    first character of firstname + first character of surname + last for
    digits of the id + "domain.ac.uk"

    e.g. makeEmail("Smith:John:83702794") returns ""

    Your help is greatly appreciated. Kind regards,

    Andrew Tegala
     
    Andrew Tegala, Aug 13, 2003
    #1
    1. Advertising

  2. Andrew Tegala

    Neomorph Guest

    On 13 Aug 2003 15:44:49 -0700, (Andrew
    Tegala) two-finger typed:

    >Dear All,
    >
    >I would like help with creation of a few Java Programs.


    Looks like perfect student work to me ;-)
    I'll give you a few pointers, but you'll have to do the grunt work
    yourself...

    >
    >Mainly, a program to change the extension of a file, from .txt to
    >.lst. It needs to take teh filename as a command line argument and
    >outputs a 'list' file.
    >
    >For example the text file, "test.txt"
    >This is a
    >small text file
    >The end.


    Reading text files is easiest with the FileReader class.
    To read lines from a text file, you can use either the BufferedReader or
    the LinenumberReader on top of the FileReader. Both have a .readLine()
    method. The second one even keeps track of the line number...

    >
    >Would be produce a file, "test.lst"
    >
    >1 This is a
    >2 small text file
    >3 The end.


    Writing a file is done using the FileWriter on which you could use a
    PrintWriter for the 'printing' of lines and other things to the file.

    Changing the extension is easy using String's lastIndexOf method (searching
    for the dot).

    >
    >Another program I need help with is to take student details from a
    >text file and output the e-mail address.
    >
    >Using the String, StringTokenizer and StringBuffer classes.
    >
    >The details are in the form of "surname:firstname:id"
    >
    >output should be
    >
    >first character of firstname + first character of surname + last for
    >digits of the id + "domain.ac.uk"
    >
    >e.g. makeEmail("Smith:John:83702794") returns ""


    StringTokenizer is used to split a string according to a certain character
    (or multiple characters).
    Use the .nextToken() to get the seperate parts one at a time.

    You're going to need Strings .substring() .toLowerCase() and StringBuffer's
    ..append().

    >
    >Your help is greatly appreciated. Kind regards,
    >
    >Andrew Tegala


    Check out the JavaDoc documentation that is seperately downloadable from
    the JDK - it's the best reference you can use.

    Cheers.
     
    Neomorph, Aug 14, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Terrance N. Phillip

    System Independent Wallpaper Changer

    Terrance N. Phillip, Jul 6, 2005, in forum: Python
    Replies:
    4
    Views:
    481
    Terrance N. Phillip
    Jul 6, 2005
  2. RigasMinho

    XSL page update URL changer?

    RigasMinho, Mar 27, 2007, in forum: XML
    Replies:
    4
    Views:
    521
    Simon Brooke
    Mar 28, 2007
  3. Joe Redshaw

    Innovator/Game Changer Wanted...

    Joe Redshaw, Dec 7, 2007, in forum: Java
    Replies:
    1
    Views:
    326
    Andrew Thompson
    Dec 8, 2007
  4. Oli Watts

    Date-based Events Calendar Changer

    Oli Watts, Jul 14, 2003, in forum: Javascript
    Replies:
    0
    Views:
    212
    Oli Watts
    Jul 14, 2003
  5. Alan Clark

    Simple document changer in a frame.

    Alan Clark, Aug 9, 2003, in forum: Javascript
    Replies:
    2
    Views:
    85
    Alan Clark
    Aug 12, 2003
Loading...

Share This Page