How to convert a text file in lower case to upper case?

I've a beginner in java world and I just come through the tutorial in http://java.sun.com/docs/books/tutorial/essential/io/filestreams.html showing how to copy a text file:
import java.io.*;
public class Copy {
public static void main(String[] args) throws IOException {
     File inputFile = new File("farrago.txt");
     File outputFile = new File("outagain.txt");
FileReader in = new FileReader(inputFile);
FileWriter out = new FileWriter(outputFile);
int c;
while ((c = in.read()) != -1)
out.write(c);
in.close();
out.close();
And I would like to ask how to covert all lower case letters in input file to upper case letter in output file at the same time of copying.
I guess it'll be using Character.toUpperCase(c), but I don't know how to do it actually.
Any help would be much appreciated.

Hope this helps
import java.io.*;
public class Copy {
public static void main(String[] args) throws IOException {
File inputFile = new File("farrago.txt");
File outputFile = new File("outagain.txt");
FileReader in = new FileReader(inputFile);
FileWriter out = new FileWriter(outputFile);
BufferedReader buff = new BufferedReader(in);
String c;
while ((c = buff.readLine()) != null)
out.write(c.toUpperCase());
in.close();
out.close();
}

Similar Messages

  • How to convert the TEXT file into an XML using plsql code

    Hi all ,
    I need to convert an TEXT file into an XML file how can i do it
    Below is my sample TEXT file .
    TDETL00000000020000000000000120131021115854ST2225SKU77598059          0023-000000010000
    I want the above to be converted into the below format
    <?xml version="1.0" encoding="UTF-8"?>
    <txt2xml>
      <!-- Processor splits text into lines -->
      <processor type="RegexDelimited">
      <regex>\n</regex>
            <!--
            This is used to specify that a message should be created per line in
            the incoming file;
            NOTE: this was designed to work with all the processors, however it
            only works correctly with 'RegexDelimited' processors (check the
            enclosing top processor type)
             -->
             <maxIterationsPerMsg>1</maxIterationsPerMsg>
      <!-- For lines beginning with FHEAD (File Header) -->
      <processor type="RegexMatch">
      <element>FHEAD</element>
      <regex>^FHEAD(.*)</regex>
      <processor type="RegexMatch">
      <element>OriginalLine</element>
      <regex>(.*)</regex>
      <consumeMatchedChars>false</consumeMatchedChars>
      </processor>
      <processor type="RegexMatch">
      <element>LineSeq,Type,Date</element>
      <regex>^(\d{10})(\w{4})(\d{14})$</regex>
      </processor>
      </processor>
      <!-- For lines beginning with TDETL (Transaction Details) -->
      <processor type="RegexMatch">
      <element>TDETL</element>
      <regex>^TDETL(.*)</regex>
      <processor type="RegexMatch">
      <element>OriginalLine</element>
      <regex>(.*)</regex>
      <consumeMatchedChars>false</consumeMatchedChars>
      </processor>
      <processor type="RegexMatch">
      <element>LineSeq,TransControlNumber,TransDate,LocationType,Location,ItemType,Item,UPCSupplement,InventoryStatus,AdjustReason,AdjustSign,AdjustQty</element>
      <regex>^(\d{10})(\d{14})(\d{14})(\w{2})(\d{4})(\w{3})([\w ]{13})([\w ]{5})(\d{2})(\d{2})([+-]{1})(\d{12})$</regex>
      </processor>
      </processor>
      <!-- For lines beginning with FTAIL (File Tail) -->
      <processor type="RegexMatch">
      <element>FTAIL</element>
      <regex>^FTAIL(.*)</regex>
      <processor type="RegexMatch">
      <element>OriginalLine</element>
      <regex>(.*)</regex>
      <consumeMatchedChars>false</consumeMatchedChars>
      </processor>
      <processor type="RegexMatch">
      <element>LineSeq,TransCount</element>
      <regex>^(\d{10})(\d{6})$</regex>
      </processor>
      </processor>
      </processor>
    </txt2xml>
    Thanks

    Sorry, that doesn't make much sense.
    The XML you gave is a configuration file for txt2xml utility. It doesn't represent the output format.
    Are you a user of this utility?

  • How to convert CSV/Text files to XML format

    Hi,
    I am trying to convert a .csv/.txt(Flat) file(s) to XML format. How can i achive this?
    Ex: I want to convert this text file to XML.
    Book#      first name                                last name                               ID#                 ID1#      F#
    B99          FRISBY                                  NASIER                                  LUCJ A         A 3127      1    
    B131         HAWKINS                              MICHAEL                               LUCJ A         A 3129       2    
    B313         KING                                     JOSHUA                                 CUCJ I         I-DORM      10   
    B307         GRAVES                               KIMBERLY                              NUCJ F         F-DORM     24-FL
    R469         HEATH                                  DARRELL                                SUCJ A         A 3132       1    
    R212         PEREZ                                  DARRELL                                SUCJ A         A 3133       2    
    R62          COFFEY                                GREGORY                               NUCJ HC      H C 3112    3FLOOR
    R215         BLACKWELL                          DEREK                                   LUCJ OOW     W 01       1     Could anyone please suggest me if we have any open source java api to acheive this?
    Thanks,
    Srikanth.

    Have a look at [http://servingxml.sourceforge.net/|http://servingxml.sourceforge.net/] or [http://www.talend.com/|http://www.talend.com/]

  • How to convert a text file content to String in JSP?

    Hi,
    I need to read the content of a text file and convert it into String and display it on to a JSP file.
    But the codings below don't work. Please advise me on how can i display the text file content.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    File adCheck = new File("list.txt");
    fis = new FileInputStream(adCheck);
    int Length = adCheck.length();
    byte arr[] = new byte[Length];
    int dataRead = 0;
    int totalData = 0;
    while(totalData <Length)
         dataRead = fis.read(arr,totalData,Length);
         totalData += dataRead;
    String Content = new String(arr);//byte array converted to String
    arr = null;

         InputStreamReader in=new InputStreamReader(fis);
          StringWriter out=new StringWriter();
          char[] buffer=new char[8192];
          int sizeRead;
          while ( ( sizeRead=in.read(buffer, 0, 8192) ) != -1 )
            out.write(buffer, 0, sizeRead);
         String content=out.toString();

  • Converting a text file into a String

    I need to convert a text file (in whatever format, in my case it would be xml and xsl files) in a String.
    I made this methods:
    public static String createStringFromFile(File f) {
            StringBuffer buf = new StringBuffer();
            try {
                FileInputStream fInp = new FileInputStream(f);
                byte[] byteArray = new byte[fInp.available()];
                int bLetti = fInp.read(byteArray);  
                if (bLetti == fInp.available()) {
                    for (int i=0; i<fInp.available(); i++)
                        buf.append(Byte.toString(byteArray));
    else
    throw (new IOException("Errore nella lettura del file"));
    fInp.close();
    } catch (Exception e) {
    ErrorManager.getError(e);
    return (buf.toString());
    public static String createStringFromFile(String fileName) {
    StringBuffer buf = new StringBuffer();
    try {
    FileInputStream fInp = new FileInputStream(fileName);
    byte[] byteArray = new byte[fInp.available()];
    int bLetti = fInp.read(byteArray);
    if (bLetti == fInp.available()) {
    for (int i=0; i<fInp.available(); i++)
    buf.append(Byte.toString(byteArray[i]));
    else
    throw (new IOException("Errore nella lettura del file"));
    fInp.close();
    } catch (Exception e) {
    ErrorManager.getError(e);
    return (buf.toString());
    There are no compilation or runtime errors, but the result string is empty. Not null, empty. What should I do? :)

    Do you really want to use bytes and so on when java does it all for you?
    Here's how I did it, hope it's useful.
    public String getFileAsString(String fileName){
         StringBuffer buffer = new StringBuffer();
         try{
         BufferedReader bRead = new BufferedReader(new FileReader(new File(fileName)));
         String str = "";
         while( (str = bRead.readLine()) != null ){
              buffer.append(str);
         }//end while
         bRead.close();
         }catch(Exception e){
         System.err.println("in getFileAsString(): " + e.toString());
         }//end try
         return buffer.toString();
    }//end getAsString()

  • How to find SVG coordinates which have been converted to text file?

    Hi all,
    I am currently developing a system that will read svg file. As svg file can be converted to text file, i already converted it. The problem is how is i going to read the coordinates provided by svg?I just want to read all the coordinates, nothing else...I hope you all can help.
    Regards..
    Edited by: Tommy1986 on Jul 8, 2008 12:45 AM
    Edited by: Tommy1986 on Jul 8, 2008 12:47 AM

    <?xml version="1.0" standalone="no"?>
    <svg width="6.666667in" height="4.166667in" viewBox="-0.000000 -0.000000 6.666667 4.166667">
    <g transform="matrix(1,0,0,-1,0,4.166667)">
    <polyline id="1" stroke="#000000" stroke-width="0.007874" fill="none" points="1.218750,2.614583 1.239583,2.666667 1.364583,2.791667 1.395833,2.885417 " />
    <polyline id="2" stroke="#000000" stroke-width="0.007874" fill="none" points="1.656250,2.802083 1.364583,2.802083 1.322917,2.541667 1.296875,2.489583 1.296875,2.364583 1.406250,2.260417 1.468750,2.244792 1.875000,2.244792 " />
    <path id="3" d=" M1.887762,2.247006 A0.531129,0.531129 0 0,1 1.657914,2.815088 " fill="none" stroke="#000000" stroke-width="0.007874" />
    </g>
    </svg>
    Hi BatraAnkit,
    Thank you very much for replying in my post. I really appreciate it Above is an example of svg file. What I am tring to do is to read only the polyline and the path collumn. Is there anyway to do it? As you can see, the svg is in xml format. Looking forwards to your reply..
    Regards,
    Tommy1986

  • How to convert a Excel file to a text file

    Hi,
    Anyone knows how to convert a excel file to a test file in java.
    Thanks
    John

    hi
    The question is not easy to respond. The easy way is to use the excel program itself! You can read the contents of an excel file using jdbc. Have a look at javaworld for an introduction (�It�s Excel-lent�). Another approach is to use a native library like JExcelApi. Have a look at http://www.andykhan.com/jexcelapi/index.html
    best regards
    benny

  • Does anyone know how to convert an XML file to a readable file?

    All,
    I have been using an APP called "SMS Backup & Restore" to backup my message conversations to my Laptop PC.  It works fine BUT the backup file, once in my PC, has an XML extent such as "filename.XML"
    I would like to read and/or print and/or save the text message file so does anyone know how to convert the XML file to something else so it shows all the messages without all the formatting instructions.   
    When I try to see the XML file it shows all the formatting.  If I replace the .XML with .TXT that too shows all the formatting mixed in with the text message narrative.
    When I look at the XML file in SMS Backup & Restore in the Charge phone it looks great showing all the messages just as they were on the phones display.  The problem with this is that there is no way to print or read or save the messages as they appear in the file from the phone itself.  I tried screen capture but if you have, let's say, a 28 message conversation you have to do 7 or 8 screen captures to get them all.
    If only I could convert the XML in my PC to something that is printable or savable or readable that would be the "cats meow."
    Anyone know how???
    JerryF
    PS, You might take a look at my related post.
    https://community.verizonwireless.com/message/809832#809832

    Ann154,
    You were correct again.  I deleted everything I had done to date and re-did the entire SMS backup of my 28 message conversation again and YES I was able to open it using IE-8.  It looks great and it prints great and life is good!  I am going to go make a donation.
    Thanks again for the help.  I marked this thread as answered by you.
    JerryF

  • How to read a text file using Java

    Guys,
    Good day!
    Please help me how to read a text file using Java and create/convert that text file into XML.
    Thanks and God Bless.
    Regards,
    I-Talk

         public void fileRead(){
                 File aFile =new File("myFile.txt");
             BufferedReader input = null;
             try {
               input = new BufferedReader( new FileReader(aFile) );
               String line = null;
               while (( line = input.readLine()) != null){
             catch (FileNotFoundException ex) {
               ex.printStackTrace();
             catch (IOException ex){
               ex.printStackTrace();
         }This code is to read a text file. But there is no such thing that will convert your text file to xml file. You have to have a defined XML format. Then you can read your data from text files and insert them inside your xml text. Or you may like to read xml tags from text files and insert your own data. The file format of .txt and .xml is far too different.
    cheers
    Mohammed Jubaer Arif.

  • Hi friends, how to process a text file.?

    1)how to process a text file.?

    Hi Ganga,
    Use following scenarios:-
    /people/venkat.donela/blog/2005/03/03/introduction-to-simple-file-xi-filescenario-and-complete-walk-through-for-starterspart2
    /people/venkat.donela/blog/2005/03/02/introduction-to-simplefile-xi-filescenario-and-complete-walk-through-for-starterspart1
    /people/srinivas.vanamala2/blog/2007/02/05/step-by-step-guide-xml-file-2-xml-file-scenario-part-ii
    /people/srinivas.vanamala2/blog/2007/02/05/step-by-step-guide-xml-file-2-xml-file-scenario-part-i
    /people/divya.vidyanandanprabhu/blog/2005/06/28/converting-xml-to-pdf-using-xi
    /people/venugopalarao.immadisetty/blog/2007/01/24/troubleshooting-file-to-idoc-scenario-in-xi
    /people/prateek.shah/blog/2005/06/08/introduction-to-idoc-xi-file-scenario-and-complete-walk-through-for-starters
    Vishal
    Reward points for useful reply

  • How to upload a text file from a shared folder and provide an o/p

    how to upload a text file from a shared folder and provide an o/p  containing the details in each order in the text file

    Hi,
    Use <b>GUI_UPLOAD</b> to upload a text file from a shared folder.
    Use <b>GUI_DOWNLOAD</b> to download data in a file on the presentation server or use <b>OPEN DATASET, TRANSFER</b> and <b>CLOSE DATASET</b> statements to download data to the application server.
    Now, I hope the code for data fetching, if required, is already present in the report.
    Reward points if the answer is helpful.
    Regards,
    Mukul

  • How to convert the javasource file(*.class) to execute file(*.exe)?

    How to convert the javasource file(*.class) to execute file(*.exe)?
    thank you!

    Although i have seen a few programs (that are platform specific) that will embed a small jvm into an exe with your class file, it is generally excepted that you cannot create an executable file using java. The JAR executable file is probably the closest your going to get
    Pete

  • How to convert java class file version without decompiling

    Hi,
    Oracle R12.1.3 i am having illegal access error while try to access the class file version Java 1.3 uses major version 47,So how to convert the class file version without using decompiling.
    Current java version is 1.6.0_07
    Is there any tool or API for converting class file version?
    Thanks,
    Selvapandian T

    Beside this I wonder where you get your error from since AFAIK 12c comes with java 1.6.
    Well wonder no more!
    OP isn't using Oracle 12c database.
    They are using Oracle R12.1.3 - which is the E- Business Suite.

  • How to convert a class file to exe file and how to cteate a class file to d

    how to convert a class file to exe file

    Hi Bhaskarq,
    Hi,
    It is not at all possible.
    But it is a really worst method.
    Please go through it.
    This is a very common question asked in the comp.lang.java newsgroup. Its often useful to have an
    executable application when deploying your
    applications to a specific platform, but remember to
    make your .class files available for users running
    Unix/Macintosh/other platforms.
    Microsoft provide a free system development kit (SDK),
    for Java, which includes the jexegen tool. This
    will convert class files into a .EXE form. The only
    disadvantage is that users need a Microsoft Java
    Virtual Machine (JVM) installed. If your target
    platform is Win32, you can either redistribute the
    virtual
    machine, or raise the level of your system
    requirements, to include Windows 98, or Windows 95
    with
    Internet Explorer 4. Systems matching these
    requirements will already have a copy of the Microsoft
    Java Virtual Machine installed.
    Note : You must specify all of the class files your
    application needs (except for standard java packges)
    as a parameter, so if you have third party libraries,
    you'll need to include them as well. You can use wildcards * though, and you don't need the original source code.
    Also please see this Forum which will give a good idea
    http://forum.java.sun.com/thread.jsp?forum=31&thread=149733
    I hope this will help you.
    Thanks
    Bakrudeen
    Technical Support Engineer
    Sun MicroSystems Inc, India

  • How to read several text files at a time

    Dear all
          Read and write one text file is not a problem, but  what confusies me is how to read several text files at one time, in the meanwhile,
    is it possible to display the name of the text file?
    For example, assuming I want to load file" cha 1, cha 2 , cha 3, " at one time and show their names, how to hadle with it
    I have reviewed some files and it is not helpful

    Either with a 'for' loop like in the lib you have attached, or like this attached VI
    that's it
    Message Edited by devchander on 05-30-2006 05:11 AM
    Attachments:
    MULTIPLE READ.vi ‏44 KB

Maybe you are looking for

  • How can I check for references to previous server and remove them?

    I recently migrated several Win7 PC's off an old sbs2003 box to a new 2012 essentials server. All client data is stored on the server in a shared folder and that is mapped to the local PC's. Everything has been great, except we have noticed a delay o

  • Can i get a refund if I ordered wrong book on ibooks and cancel it please?

    Can i get a refund and cancel a book if I ordered the wrong one on ibooks?

  • Spark DataGrid with Dynamic Column Width

    Lets suppose I have a Spark Datagrid with no explicit typicalItem. When the Datagrid is initialized, the column widths are calcualted correctly based on the contents of the dataprovider. However if I add/remove an item from the dataprovider, or modif

  • Cloning a PowerMac G4 with OS 10.3

    Hey all, For my work, we use microscope software that only works with OS 10.3 (why, I don't know). My boss is buying a second computer (and microscope) which he wants me to make exact copy of our current computer (so we can have two users working at

  • Managed System Configuration Super User Issue

    Hi folks , I have a strange error in Solman SP8 Managed System Config . In Step 5 : "Enter System Parameters" , for entering super user , it throws an error even though the user credentials are valid. This happens for some of the managed systems only