Not exactly what was asked for...

zotdog69
zotdog69 used Ask the Experts™
on
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.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

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

Commented:

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"?

Author

Commented:
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.
Awarded 2011
Awarded 2011

Commented:
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?

Author

Commented:
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.
Awarded 2011
Awarded 2011
Commented:
This is the program which does it:

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




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

                String line;
                while((line = in.readLine()) != null)
                      out.write(line.toLowerCase() + System.getProperty("line.separator"));

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


      public static void main(String[] args) {

        try{
        toLowerCase("c:\\temp\\test\\uppercase.txt", "c:\\temp\\test\\lowercase.txt");
        }catch(Exception ex){

           ex.printStackTrace();
        }

}
}

Open in new window

Awarded 2011
Awarded 2011

Commented:


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


Author

Commented:
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.
Awarded 2011
Awarded 2011

Commented:
What you mean by "outside file" ?

Author

Commented:
Thanks again for_yan!
Awarded 2011
Awarded 2011

Commented:
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.
Awarded 2011
Awarded 2011

Commented:
You are always welcome.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial