Link to home
Create AccountLog in
Avatar of zotdog69
zotdog69Flag 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.
Avatar of zotdog69
zotdog69
Flag of United States of America image

ASKER

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

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"?
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.
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?
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
Avatar of for_yan
for_yan
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account


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


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.
What you mean by "outside file" ?
Thanks again 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.
You are always welcome.