• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

A Tricky project : File Convert

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
I've just been given a small folio to be completed, and it is a small program.
What I've been told is that my program needs to ask the user to open any TEXT FILE (test.txt) that contains a document. The program will read the text file and all lower-case alphabetical characters in the original file are converted to upper-case in the new file, which means the program will also ask the user to enter a new text file, and then it will create that file to input the converted document.
I've done lots of reading on Text File I/O, but still not sure where I should start.
Could anyone give me some advices/tips on how this will work. I don't know how to use the CONVERT method??
Thanks!
 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
If you're beginning to get to grips with I/O, you're halfway there. I think the way to tackle this problem is to break it into much smaller problems.
1) Create a program that will read a text file in - hardcode the name of the text file.
2) Add to the program so that it will write exactly the same file out to a new file - hardcode the name of that new file too.
3) Now put in the funcionality to convert the first file into upper case after / as it is read in, so that the file written out is in upper case.
4) Decide how the user is going to specify the file name and add that code to your program - be it via command-line arguements, a text prompt, or a GUI file browser.
5) Tidy everything up - think about issues such as what happens if the output file already exists - do you have to deal with this or not?
So in the first attempt, I would ignore the issue of converting the text. One of the beauties of the OO approach should be that you can tackle a big problem in small chunks.
Sun's java tutorial on I/O has code examples on just about everything you need to do for I/O - so check that out at:-
Java IO tutorial
When thinking about converting the code, I'd consider using a Filter Stream or Reader or Writer - again the tutorial covers how to write your own filter stream.
If you want some information on converting Strings and Characters to upper-case, another Java tutorial might be useful.
Characters tutorial
Hope this helps - and gives you somewhere to start.
Kathy Rogers
 
crispy bacon. crispy tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic