This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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!
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