Avatar of zotdog69
zotdog69
Flag for United States of America asked on

Not exactly what was asked for...

This was the original question:
"Title:
Lowercase problems...Question: I'm working on a program for changing uppercase letters to lowercase. This is what I have so far:
class lowercase
{
Set objFileSystem = CreateObject("Scripting.fileSystemObject");
Set objOriginalFile = objFileSystem.OpenTextFile(OriginalFile,1,True)
Reader = objOriginalFile.ReadAll;
objOreginalFile.Close;

LowerCaseReader = LCase (Reader);
Set objEndFile = objFileSystem.OpenTextFile(EndFile,2,True);
objEndFile.Write LowerCaseReader;
objEndFile.Close;
Set objEndFile = Nothing;
Set objOriginalFile = Nothing;
Set objFileSystem = Nothing;
}
And these are the errors I'm getting:lowercase.java:6: <identifier> expected
Reader = objOriginalFile.ReadAll;
      ^
lowercase.java:7: <identifier> expected
objOreginalFile.Close;// read from the file then close the file
                     ^
lowercase.java:9: <identifier> expected
LowerCaseReader = LCase (Reader);//converts all to lower Case
               ^
lowercase.java:12: <identifier> expected
objEndFile.Close;//write all to the end file
                ^
4 errors
Along with the obvious errors up top, I have researched the answers on how to create a file .TXT, but am very unsure of how to do it. Keep in mind, I'm running Coderunner (MAC) and don't know if it can import/export to a file.
Thanks, this is the last program I HAVE to do, so now I can start doing programs I want to do!"

And this was the proposed solution:
"This one does what you want:

 import java.io.*;
public class LowerCase{
public static  void toLowerCase(String inFile, String outFile) throws IOException {

                  BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(inFile)));
           out.write("ASDFGBHJkling");
               out.close();


                BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(inFile)));
                 out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile)));

                String line;
                while((line = in.readLine()) != null)
                      out.write(line.toLowerCase() + "\n");

                in.close();
                out.close();
    }


      public static void main(String[] args) {

        try{
        toLowerCase("input.txt", "output.txt");
        }catch(Exception ex){

           ex.printStackTrace();
        }

}
}"
But this is what I need:
The program needs to read an input file and write it to an output file. In other words it should create an input file by typing one not by typing into the file from the program.
ProgrammingJava

Avatar of undefined
Last Comment
for_yan

8/22/2022 - Mon
zotdog69

ASKER
It opens a txt document, changes the uppercase letters to lowercase, and saves to a new txt document. Can anyone assist?
for_yan


Can you explain in some other words what you mean by this:
"create an input file by typing one not by typing into the file from the program."

What means "create an input file by typing one"?
zotdog69

ASKER
Type a tex document, save it, and place it in a folder accessilble to the program. The program then points to that file, opensit, changes it to lowercase, and saves it as a text document in the same location.

I had to get clarity on this too.
Your help has saved me hundreds of hours of internet surfing.
fblack61
for_yan

You mean you want to re-write the file under the same name?
You don't want to read from file input.txt and write to output.txt, you rather want to
read form input.txt , transfer text which you read, to lower case and write it back to the same file input.txt overwriting
the original content - that is what you want?
zotdog69

ASKER
No, file 1, named uppercase for example, gets opened and read by this program. The program processes the data, creates a new file, named lowercase for example, and sends it to the same location as the first.
ASKER CERTIFIED SOLUTION
for_yan

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
for_yan



In the folder C:\temp\test create file called uppercase.txt with this contents:

DFDDGFFGFFGjjjhjhhh
fgfggGHGJGJHJH

Open in new window


Run the above program and you'll see in the same folder the new file called
lowercase.txt will appear which will have the following two lines:

dfddgffgffgjjjhjhhh
fgfggghgjgjhjh

Open in new window


Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
zotdog69

ASKER
And this will take an outside file, change the uppercase letters to lowercase, and create a new TXT file? Sorry to ask, but my computer is in my room, and this computer doesn't have Coderunner.
for_yan

What you mean by "outside file" ?
zotdog69

ASKER
Thanks again for_yan!
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
for_yan

The folder where the input file is located and where the output file will be written needs to be accessible
from the computer where you execute the program.
If that folder is on thedifferent computer then it needs to be mapped to the computer where you execute your program.
for_yan

You are always welcome.