Text file: reading char one at a time line by line

I need to read an external .txt file, one character at a time, line by line, and compare each character in order to do various things. The problem is that when I use the Buffered Reader I have only readLine() method and others to work with, but none that actually read a character at a time, and line by line. The program has to read a character, then move to the next one and read it, and so on. Then move to the next line, and read the first character, and so on. I am working with chars not Strings. Could you please help me with this problem?

InputStreamReader can read a single char.
InputStreamReader isr = new InputStreamReader(InputStream in);
isr.read(); will return 1 character from "in".

Similar Messages

  • Is there a way I can 'select all' for downloading purchase files via family sharing instead of selecting each file or folder one at a time?

    Is there a way I can 'select all' for downloading purchase files via family sharing instead of selecting each file or folder one at a time?

    or home sharing

  • Text/File Reader that will resize/reformat Text for easy reading.

    I've used a couple of Text/File reader Apps; but with all of them,
    you have the choice of zooming out to see enough of a page to
    see an entire line of text, which is way too tiny to read, or zooming
    in so that it's easy to read, but then needing to scroll back and forth
    to read each line.
    Is there a reader that will display text large enough to read, and
    reflow/reformat the text so that it's all on the screen?
    Thanks, Jim.

    I found that Stanza does a great job reformatting most file types for reading on the iPodT. You do need the Mac OSX software for Stanza to transfer files to the iPodT so that you can read them with Stanza.
    I'm happy; but I wish the answer had been easier to find!
    Jim.

  • Write arrays into a text file in different columns at different times

    Hi,
              I have a problem write data into a text file. I want to write 4 1D arrays into a text file. The problem is that I need to write it at different time and in different column (in other word, not only append the arrays).
    Do you have an idea to solve my problem?
    Thank you

    A file is long a linear string of data (text). In order ro insert columns, you need to rewrite the entire file, because colums are interlaced over the entire lenght of the file.
    So:
    read file into 2D array
    insert columns using array operations
    write resulting 2D array to file again.
    (Only if your colums are guaranteed to be fixed width AND you know the final number of colums, you could write the missing columns as spaces and then overwrite later. Still, it will be painful and inefficient, because column data are not adjacent in the file.)
    LabVIEW Champion . Do more with less code and in less time .

  • Text file reading and writing problem

    Hello ! i am working on an electronic diary project and i am using Netbeans for that... i have finished all the rest but i am stuck into the saving of the appointments which i have been making.. i am using text files to save the entries ...what i am doing currently is that i am creating a file of every date which a user selects in the combobox.but if i want to add more appointment on the same date , then it overwries the previous one. i need to write something which can store multiple appointments in the same file.
    the writing code is:
    try {
    String aa = jTextField1.getText();
    String ab = jTextField2.getText();
    String ac =(String)jComboBox2.getSelectedItem();
    String ad =(String)jComboBox3.getSelectedItem();
    String ae = jTextField5.getText();
    String af =(String)jComboBox1.getSelectedItem();
    String ag = jTextArea1.getText();
    String outputFileName = ab+ac+ad+".txt";
    FileWriter outputFileReader = new FileWriter(outputFileName);
    PrintWriter outputStream = new PrintWriter(outputFileReader);
    PrintWriter outputStream1 = new PrintWriter(outputFileReader);
    PrintWriter outputStream2 = new PrintWriter(outputFileReader);
    PrintWriter outputStream22 = new PrintWriter(outputFileReader);
    PrintWriter outputStream3 = new PrintWriter(outputFileReader);
    outputStream.write(aa);
    outputStream1.write(ae);
    outputStream2.write(af);
    outputStream3.write(ag);
    outputStream.close();
    } catch (IOException e) {
    System.out.println("IOException:");
    e.printStackTrace();
    when i read the code , it doesnot reads the one which i store the text in new line...
    thanks

    Hi Dear
    Actually apending in your file is False so that it is overwriting this. do one thing open append option then it will add your data. for this just user true as the parameter with file name as i write in the below line. bedefault overwriting is false. you have to make this true.
    BufferedWriter out = new BufferedWriter(new FileWriter("Out.csv",true));
    try this your problem will solve.

  • Text file reading in Oracle9i Procedure

    Dear experts,
    How we can read Text File in Oracle9i Procedure.
    Thanks in advance

    can we read a file like this ??
    PROCEDURE PROCESS_AGAIN IS
         filename           varchar2(13) := 'c:\temp\RECIPIENT.TXT';
         file_handle TEXT_IO.FILE_TYPE;
         newline           varchar2(4000);
    BEGIN
         file_handle := TEXT_IO.FOPEN(filename, 'R');
         LOOP
              TEXT_IO.GET_LINE(file_handle,newline);
    /* Process */
         END LOOP;
    EXCEPTION
         WHEN NO_DATA_FOUND THEN
              TEXT_IO.FCLOSE(file_handle);
    END;

  • Utility to send text file over GPIB, one line at a time?

    We are developing instrumentation that receives data and commmands over GPIB as plain text, and returns them as well. I'd like to create GPIB "batch" files and send them over the bus, one line at a time, so I can debug the instruments' behavior. I'd also like to be able to read back responses, one line at a time.
    Is there such a utility? I've got our programmer working on something like this, but I'd hate to have him re-invent an existing wheel.
    Thanks!

    Apart from NI-SPY, I have not heard of such a utility. This may be simple to implement using proper termination. If the instrument is capable of sending line feeds or carriage return, you should be able to easily create a document. Also, using IBWRTF, you could write the ASCII file (containing the termination characters) to the bus. Depending on how you have your timeouts specified, this may be ideal.
    Alternately, if you read a static amount of data, you could IBRD chunks of data. the result may need editing for broken words at the end of a line but would achieve such a result.
    Ryan Mosley
    National Instruments, Applications Engineer
    http://www.ni.com/exchange

  • Error when reading chars values when restricting time chars in Query

    Hi all,
    since a few days I am not able to restrict time characteristics in queries on a particular Multiporvider. I can restrict the time chars with variables but not with fixed values.
    I am getting the following error:
    Reading Characteristic Values -> Programm Error in class SAPMSSY1 -> Uncaught exception.
    The problem exists only on one particular multi provider, but when checking the MP it indicates no errors.
    Anyone experienced something similiar? I am appreciating your help.
    Thomas

    actually it is a problem associated with SAP GUI 7.0.
    A solution to this problem is
    Just replace the file wdbspres.dll with in the following location
    C:\Program Files\SAP\FrontEnd\SapGui.
    You can search for this file on google and download it.
    we also had faced this problem earlier...but after replacing the wdbspres.dll...it worked..
    i hope this helps you.
    pls assign points if this answer is of some help

  • CSV file reading using UTL_FILE at run time

    Hi,
    I have to read CSV file using UTL_FILE.
    but Folder contains Many CSV files.
    I dont know there name.So i have to read csv file at run time.
    Please let me know how should we achieve this?
    Thanks

    place the following in a shell script, say "list_my_files.ksh"
    ls -l > my_file_list.datthen run the shell script using dbms_scheduler;
    begin
    dbms_scheduler.create_program (program_name   => 'a_test_proc'
                                  ,program_type   => 'EXECUTABLE'
                                  ,program_action => '/home/bluefrog/list_my_files.ksh'
                                  ,number_of_arguments => 0
                                  ,enabled => true);
    end;
    /then open "my_file_list.dat" using UTL_FILE, read all file names and choose the one you require.
    P;

  • How do I import pictures from computer files more than one at a time ?

    I recieved the adobe photoshop elements 10 for x mas and no problems with downloading the program but i am having a time importing pictures from my computer files taken from various camaras. the problem is that i can only import pictures from my files 1 at a time. what do i do ? is there a specific tutoral i need to watch ? I know i'm doing something wrong i just don't know, please help Kev

    Welcome to the forum.
    You should be able to use the Shift, or Ctrl modifier keys, to select multiple files, and Import them.
    Now, for Stills, I would strongly suggest that you Scale those Still Images to about the Frame Size of the Project, prior to Import.
    Good luck,
    Hunt

  • Text file - replace a pattern with part of the previous line? -SOLVED

    Hello, I'm stuck with sed/awk/grep...
    So I have a file with lines like this:
    Nice bunch of words <STUFF> <STUFF> <IMPORTANT_DELIMITER_TYPE_1> <STUFF> <IMPORTANT_DELIMITER_TYPE_2> <STUFF>
    Even Nicer bunch of Words <STUFF> <IMPORTANT_DELIMITER_TYPE_1> <STUFF> <STUFF> <STUFF>
    Wonderful bunch of Words <STUFF> <STUFF> <STUFF><IMPORTANT_DELIMITER_TYPE_1><STUFF>
    Then, I want to move the "important delimiters" to new lines (might be better not to do this in fact...)
    Nice bunch of words <STUFF> <STUFF>
    <IMPORTANT_DELIMITER_TYPE_1> <STUFF>
    <IMPORTANT_DELIMITER_TYPE_2> <STUFF>
    Even Nicer bunch of Words <STUFF>
    <IMPORTANT_DELIMITER_TYPE_1> <STUFF> <STUFF> <STUFF>
    Wonderful bunch of Words <STUFF> <STUFF> <STUFF>
    <IMPORTANT_DELIMITER_TYPE_1><STUFF>
    And finally, I want to replace the important delimiters with the content of the line they came from originally, up to the first angle bracket:
    Nice bunch of words <STUFF> <STUFF>
    Nice bunch of words <STUFF>
    Nice bunch of words <STUFF>
    Even Nicer bunch of Words <STUFF>
    Even Nicer bunch of Words <STUFF> <STUFF> <STUFF>
    Wonderful bunch of Words <STUFF> <STUFF> <STUFF>
    Wonderful bunch of Words<STUFF>
    How can I accomplish this using absolutely anything at all that doesn't involve too much manual effort (the file is about 30,000 lines of this stuff)
    Thanks !
    Last edited by darkbeanies (2013-09-01 19:18:29)

    "<STUFF>" is not irrelevant. In your original example
    Nice bunch of words <STUFF> <STUFF> <IMPORTANT_DELIMITER_TYPE_1> <STUFF> <IMPORTANT_DELIMITER_TYPE_2> <STUFF>
    Even Nicer bunch of Words <STUFF> <IMPORTANT_DELIMITER_TYPE_1> <STUFF> <STUFF> <STUFF>
    Wonderful bunch of Words <STUFF> <STUFF> <STUFF><IMPORTANT_DELIMITER_TYPE_1><STUFF>
    you want to break the lines along the delimiters:
    Nice bunch of words <STUFF> <STUFF>
    <IMPORTANT_DELIMITER_TYPE_1> <STUFF>
    <IMPORTANT_DELIMITER_TYPE_2> <STUFF>
    Even Nicer bunch of Words <STUFF>
    <IMPORTANT_DELIMITER_TYPE_1> <STUFF> <STUFF> <STUFF>
    Wonderful bunch of Words <STUFF> <STUFF> <STUFF>
    <IMPORTANT_DELIMITER_TYPE_1><STUFF>
    and then you say that you want to replace the delimiters with the contents before the first angle bracket:
    Nice bunch of words <STUFF> <STUFF>
    Nice bunch of words <STUFF>
    Nice bunch of words <STUFF>
    Even Nicer bunch of Words <STUFF>
    Even Nicer bunch of Words <STUFF> <STUFF> <STUFF>
    Wonderful bunch of Words <STUFF> <STUFF> <STUFF>
    Wonderful bunch of Words<STUFF>
    but you have clearly made a distinction between the "nice bunch of words" and "<STUFF>", otherwise the output would have been
    Nice bunch of words <STUFF> <STUFF>
    Nice bunch of words <STUFF> <STUFF> <STUFF>
    So, do you want everything up to  the first delimiter, or do you want everything up to <STUFF> in the replacement? If you only want the "nicer words" then you need some way to distinguish between them and "stuff" programmatically.
    edit
    Here's a trivial script that will split the lines along the delimiters and replace them with the contents of the line before the first delimiter:
    #!/usr/bin/env python3
    import re
    import sys
    def main(args=None):
    for line in sys.stdin:
    # Trim trailing newline.
    line = line.rstrip('\n')
    # Split by delimiters.
    parts = re.split(r'<[^>]+>', line)
    print(parts[0])
    for p in parts[1:]:
    print(parts[0] + p)
    if __name__ == '__main__':
    try:
    main()
    except (KeyboardInterrupt, BrokenPipeError):
    pass
    Usage
    path/to/script < /path/to/input file
    Last edited by Xyne (2013-09-01 18:34:55)

  • During file read it is cutting first character of first line

    This program has a file 7918.txt
    with contents
    user=ry;checkout=yes;checkin=yes
    user=dg;checkout=yes;checkin=yes
    user=nik;checkout=yes;checkin=yes
    user=dg;checkout=yes;checkin=yes
    when i am trying to read it is displaying (or storing it to another file) after cutting first letter of first line.
    ser=ry;checkout=yes;checkin=yes
    user=dg;checkout=yes;checkin=yes
    user=nik;checkout=yes;checkin=yes
    user=dg;checkout=yes;checkin=yes
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class txtSearch2 extends HttpServlet {
    // PrintWriter out =null;
    public void doGet(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
         PrintWriter out = res.getWriter();
         String user="nik";
         String filename="7918";
         try{
                   BufferedReader br =null;
                   File tt = new File("myserver/servletclasses/"+filename+".txt");
    int ind=0;
                   int lno=0;
                   int i=0;
              if( tt.exists() ){
                   br = new BufferedReader(new FileReader("myserver/servletclasses/"+filename+".txt"));
                   String s, s2 = new String();
                   while(br.read()!=-1)
                        while((s = br.readLine())!=null)
                             out.println("S_______ "+s);
                        s2 += s + "\n";     
                             out.println("S222_______ "+s2);
                             if (s.indexOf(user) > -1)
                             { out.println("LINE NO "+lno);
                             ind=lno;
                             out.println("INDEX "+ind);
                             lno++;
              BufferedWriter      bw
              = new BufferedWriter(
              new OutputStreamWriter(new
              FileOutputStream("myserver/servletclasses/"+filename+"x.txt")));
              bw.write(s2);
              out.println("SSSSSSSSSSSSSSSS@@@@@@@@@@@@@@@@@@222222"+s2);
              bw.flush();
    br.close();     
              bw.close();
    out.println(" INDNO "+ind);
    out.println("LINE NO3///////////////////////// "+lno);
         }catch(FileNotFoundException f)
         catch(IOException io)
    Thanks

    Look carefully at your code:
    while(br.read()!=-1)
    while((s = br.readLine())!=null)See where you chop off the first character?

  • How to read some records from a text file into java(not all records)

    hello,
    how to read text files into java. i need only few records from the text file not all records at a time.
    If any one knows plz reply me
    my id is [email protected]

    this snipet reads a text file line by line from line 1 to 3
    try {
                  FileReader fr = new FileReader(directory);
                  BufferedReader br = new BufferedReader(fr);
                  int counter = 0;
                  while ((dbconn = br.readLine()) != null) {
                      switch(counter){
                          case 0:
                            status = dbconn;
                          break;
                          case 1:
                            userName = dbconn;
                          break;
                          case 2:
                            apword = dbconn;
                          break;
                      counter++;
                  br.close();
        }catch(IOException e){
        }

  • Getting repeated values when reading from a text file.

    I need to read from a text file. When the token encounters a particular word (command) I need to read the next line and perform some actions. However, this part is working but it is repeating the values again and again until it encounters the next particular word (command). Hope that someone will help me out, as always when I posted a problem in these forums.
    SetOperations class - contains the set methods
    // Imported packages.========================================================
    import java.util.Vector;
    import java.util.Iterator;
    // Public class SetOperations.===============================================
    public class SetOperations
         // Instance variables.===================================================
         private Vector v = null; // Creates new instance of vector.
         protected int memberCount;
         // Constructor.==========================================================
         public SetOperations()
              v = new Vector();
         } // end constructor.
         // Method isMember.======================================================
         * Checks whether the element is already a member of the set.
         * @return True if Vector v contains Object member.
         public boolean isMember(Object member)
              if (member != null) // only if Object member is not null.
                   return v.contains(member); // returns true if vector already contains member.
              else
                   return false; // returns false if vector does not contain member.
         } // end public boolean isMember(Object member).
         // Method addMember.=====================================================
         * Adds a member to the set.
         * @return Adds Object member to Vector v.
         public void addMember(Object member)
              //if (! v.contains(member)) // only if element is not already a member.
              if (isMember(member) == false) // only if element is not already a member.
                   v.add(member); // adds a member.
         } // end public void addMember(Object member).
         // Method countMember.===================================================
         * Returns the number of members present in the vector.
         * @return Number of elements present in the vector.
         public int countMember()
              return v.size();
         } // end public int countMember().
         // Method isSetEmpty.====================================================
         * Returns true if set is empty.
         * @return True if no elements are present in Vector v.
         public boolean isSetEmpty()
              return v.size() == 0; // returns 0 if no elements are present in the vector.
         } // end of public boolean isSetEmpty().
         // Method printMember.===================================================
         * Displays member/s of the set.
         * @return Prints element/s present in the vector.
         public void printMember()
              for (int i = 0; i < v.size(); i++) // iterates through present members.
                   System.out.println("[" + i + "] " + v.get(i)); // displays member/s present in the vector.
         } // end of public void printMember().
    } // end public class SetOperations.
    SetTextLauncher class - reads from a text file and implements the set operations
    // Imported packages.========================================================
    import java.util.*;
    import java.io.*;
    // Public class SetTestLauncher.=============================================
    public class SetTestLauncher
         // Main method public static void main(String args[]).===================
         public static void main(String args[])
              displayFile("test.txt"); // outputs result from text file.
         // method to display a file on screen
         public static void displayFile (String textFile)
              // Instance variables.===============================================
              // Creates new instances of SetOperations.
              SetOperations setA = new SetOperations();
              SetOperations setB = new SetOperations();
              SetOperations setC = new SetOperations();
              SetOperations setD = new SetOperations();
              SetOperations setE = new SetOperations();
              // Initialisation.
              String line = "", nextLine = "";
              FileReader fr = null;
              try
                   // Opens the file with the FileReader data sink stream.
                   fr = new FileReader(textFile);
                   // Converts the FileReader input stream with the BufferedReader processing stream.
                   BufferedReader br = new BufferedReader(fr);
                   // Iterates through text file reading lines until end of text lines.
                   while (line != null)
                        line = br.readLine(); // reads one line at a time.
                        if(line == null) break; // when the line is null break the loop.
                        // Creates a new instace of StringTokenizer.
                        StringTokenizer st = new StringTokenizer(line);
                        // Loops until there are no more tokens.
                        while (st.hasMoreTokens())
                             String token = st.nextToken(); // reads next token.
                             // Only if the token encounters the String "membera".
                             if(token.equals("membera"))
                                  nextLine = br.readLine(); // gets next line.
                                  setA.addMember(nextLine); // adds a member to the set.
                                  // Displays members present in the set if vector is not empty.
                                  if (! setA.isSetEmpty())
                                       setA.printMember(); // print members present.
                                  // Displays the number of member/s present in the vector.
                                  System.out.println("Number of set members: " + setA.countMember());
              // Catches and displays exceptions.
              catch (FileNotFoundException exp)
                   System.out.println(exp.getMessage());
                   exp.printStackTrace();
              catch (IOException exp)
                   System.out.println(exp.getMessage());
                   exp.printStackTrace();
              finally
                   try
                        // if file is found
                        if (fr != null)
                             // close file
                             fr.close();
                   catch (IOException exp)
                        exp.printStackTrace();
         } // end public static void main(String args[]).
    } // end public class SetTestLauncher.

    Thanks for your interest. Please ignore SetOperations class, it is just the class containing the methods and it works correctly since I checked it without reading from a text file. I marked the part where I think lies my problem in class SetTestOperations.
    The information in the text file is as follows:
    membera
    Hillman
    membera
    Skoda
    membera
    Honda
    membera
    Toyota
    and the result is:
    [0] Hillman
    Number of set members: 1
    [0] Hillman
    [1] Skoda
    Number of set members: 2
    [0] Hillman
    [1] Skoda
    [2] Honda
    Number of set members: 3
    [0] Hillman
    [1] Skoda
    [2] Honda
    [3] Toyota
    Number of set members: 4
    instead of just one set:
    [0] Hillman
    [1] Skoda
    [2] Honda
    [3] Toyota
    Number of set members: 4
    Hope it is easier to understand like this.
    Regards
    Marco
    I need to read from a text file. When the token
    encounters a particular word (command) I need to read
    the next line and perform some actions. However, this
    part is working but it is repeating the values again
    and again until it encounters the next particular
    word (command). Hope that someone will help me out,
    as always when I posted a problem in these forums.
    SetOperations class - contains the set
    methods
    // Imported
    packages.=============================================
    ===========
    import java.util.Vector;
    import java.util.Iterator;
    // Public class
    SetOperations.========================================
    =======
    public class SetOperations
    // Instance
    e
    variables.============================================
    =======
    private Vector v = null; // Creates new instance of
    f vector.
         protected int memberCount;
    Constructor.==========================================
    ================
         public SetOperations()
              v = new Vector();
         } // end constructor.
    // Method
    d
    isMember.=============================================
    =========
    * Checks whether the element is already a member of
    f the set.
         * @return True if Vector v contains Object member.
         public boolean isMember(Object member)
    if (member != null) // only if Object member is not
    ot null.
    return v.contains(member); // returns true if
    if vector already contains member.
              else
    return false; // returns false if vector does not
    not contain member.
         } // end public boolean isMember(Object member).
    // Method
    d
    addMember.============================================
    =========
         * Adds a member to the set.
         * @return Adds Object member to Vector v.
         public void addMember(Object member)
    //if (! v.contains(member)) // only if element is
    is not already a member.
    if (isMember(member) == false) // only if element
    nt is not already a member.
                   v.add(member); // adds a member.
         } // end public void addMember(Object member).
    // Method
    d
    countMember.==========================================
    =========
    * Returns the number of members present in the
    e vector.
         * @return Number of elements present in the vector.
         public int countMember()
              return v.size();
         } // end public int countMember().
    // Method
    d
    isSetEmpty.===========================================
    =========
         * Returns true if set is empty.
    * @return True if no elements are present in Vector
    r v.
         public boolean isSetEmpty()
    return v.size() == 0; // returns 0 if no elements
    ts are present in the vector.
         } // end of public boolean isSetEmpty().
    // Method
    d
    printMember.==========================================
    =========
         * Displays member/s of the set.
         * @return Prints element/s present in the vector.
         public void printMember()
    for (int i = 0; i < v.size(); i++) // iterates
    es through present members.
    System.out.println("[" + i + "] " + v.get(i)); //
    // displays member/s present in the vector.
         } // end of public void printMember().
    } // end public class SetOperations.
    SetTextLauncher class - reads from a text file
    and implements the set operations
    // Imported
    packages.=============================================
    ===========
    import java.util.*;
    import java.io.*;
    // Public class
    SetTestLauncher.======================================
    =======
    public class SetTestLauncher
    // Main method public static void main(String
    g args[]).===================
         public static void main(String args[])
    displayFile("test.txt"); // outputs result from
    om text file.
         // method to display a file on screen
         public static void displayFile (String textFile)
    // Instance
    ce
    variables.============================================
    ===
              // Creates new instances of SetOperations.
              SetOperations setA = new SetOperations();
              // Initialisation.
              String line = "", nextLine = "";
              FileReader fr = null;
              try
    // Opens the file with the FileReader data sink
    ink stream.
                   fr = new FileReader(textFile);
    // Converts the FileReader input stream with the
    the BufferedReader processing stream.
                   BufferedReader br = new BufferedReader(fr);
    // Iterates through text file reading lines until
    til end of text lines.
                   while (line != null)
    line = br.readLine(); // reads one line at a
    at a time.
    if(line == null) break; // when the line is null
    null break the loop.
                        // Creates a new instace of StringTokenizer.
                        StringTokenizer st = new StringTokenizer(line);
                        // Loops until there are no more tokens.
                        while (st.hasMoreTokens())
    String token = st.nextToken(); // reads next
    next token.
    // Only if the token encounters the String
    tring "membera".
                             if(token.equals("membera"))
                                  // *****THE PROBLEM LIES HERE....I GUESS
    // need to read the next line after encountering the word membera in text file
    nextLine = br.readLine(); // gets next line.
    setA.addMember(nextLine); // adds a member to
    ber to the set.
    // Displays members present in the set if
    set if vector is not empty.
                                  if (! setA.isSetEmpty())
                                       setA.printMember(); // print members present.
    // Displays the number of member/s present in
    ent in the vector.
    System.out.println("Number of set members: " +
    s: " + setA.countMember());
              // Catches and displays exceptions.
              catch (FileNotFoundException exp)
                   System.out.println(exp.getMessage());
                   exp.printStackTrace();
              catch (IOException exp)
                   System.out.println(exp.getMessage());
                   exp.printStackTrace();
              finally
                   try
                        // if file is found
                        if (fr != null)
                             // close file
                             fr.close();
                   catch (IOException exp)
                        exp.printStackTrace();
         } // end public static void main(String args[]).
    } // end public class SetTestLauncher.

  • How to adjust splitted lines into one line in Text file?

    Hi Guys,
    I have a text file with 3 fields(comma separated): GLCode (Number), Desc1 (Char), Desc2(Char) and need to load it into BW.
    My Text file looks like:
    1011.00,"Mejor PC Infrastructure","This line is ok."
    1012.00,"Telephone Equipment $","This line ends in next line.   
    1)Need to change the equipment immediately.
    2)Take immediate action"
    1013.00,"V1 Computer Server Infrastructure # Equip","For purchases
    of components that make up the company's network, such as servers, hubs, routers etc."
    1014.00,"Flash Drive","Need to provide all IT Developer"
    This is how file looks like. Now I need the followings:
    1. Need to remove the space and need to adjust the splitted line into one. Say here
    line/record 2 is splitted into 3 lines and need to adjust in 1 line.
    2. In Line 5 (Record 3) data splitted into 2 lines and need to make 1 line.
    3. Need to remove bad characters.
    Could someone help me please how to proceed ?
    Regards,

    Not quite correct by my testing.  Try:
    $i=0
    Get-Content .\test.txt | ForEach {
    If ($i%2){
    ("$Keep $($_)").Trim()
    }Else{
    $keep=$_
    }$i++
    Good catch!
    Boe Prox
    Blog |
    Twitter
    PoshWSUS |
    PoshPAIG | PoshChat |
    PoshEventUI
    PowerShell Deep Dives Book

Maybe you are looking for