Link to home
Start Free TrialLog in
Avatar of evan224
evan224

asked on

reading a file, running toUpperCase then writing to another file

I am able to read Strings in and out of a .txt file.  I am also able to apply toUpperCase to a String and output it to a .txt file.  I cannot however capitalize a string that has been sucked from a .txt file.  Plus using toUpperCase adds spaces after each of the characters.

Hope you can help, code is available.

evan224@hotmail.com  
SOLUTION
Avatar of nir2002
nir2002

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
following works for me .. .. and should work for you also .. modify according to ur needs

import java.io.*;

public class test
{
 public static void main( String[] args )
   {
        String line=null;
        if(args.length >=2){
        try
                 {
                  BufferedReader in = new BufferedReader(new FileReader( args[0] ) );
                  FileWriter out =new FileWriter(args[1]);
                  while ( (line =in.readLine())!=null )  // continue until end of file
                      {
                       System.out.println( line );
                    out.write(line.toUpperCase()+"\n");

                      }

                  in.close();
                  out.close();
                 }
             catch ( IOException iox )
                 {
                    iox.printStackTrace();
              }

          }
          else System.out.println("usage :: java test <inFile> <outUpperCaseFile>");
     }
}
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CleanupPing
CleanupPing

evan224:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
split, me and nir2002
i dont see the reason behind a 'C'.
some moderator can check on this.