Insert filler in text file

Hi...
Well .... i am using Clover Etl... tool for reading a text file and then performing some operations on it.... Each record on the text file is on a new line...Now what i would like to do is that make each line of the same length . For eg. i have these lines
aaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbb
ccccccccccccccccccc
Now what should happen is this
aaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbb
cccccccccccccccccccc*******
Some char should be inserted at the end so that the particular line becomes of the same length as others.Is there anyy way it could be done using java.... if so please telll me something about it...Thanx

Simply fill up the lines before you write them.
aStringBuffer.append(asManyFillersAsYouNeed);
writer.println(aStringBuffer.toString());

Similar Messages

  • How can u insert and retrieve text files in any format using forms6i.

    how can u insert and retrieve text files in any format using forms6i.
    can u give me an example of an insert statement, let's assume the file is located in the a:drive.
    and retrieving the files, i would give the user a list of all the files that are in the database, the user would select one, but what command(or piece of code) would open the file in its apppropriate editor.
    e.g .pdf formatted file would open in acrobat.
    any help would be appreciated.
    Thanks
    Hussein Saiger

    the filereference class is for downloading and uploading files.
    if you want to load xml, use the xml class.
    and, if you want to write to an xml file and don't want to use server-side code, wait.

  • Fill a text file from java code

    Hello,
    I've written a java code to insert some informations in a database and
    I also want to save the same informations in text files (.txt).
    Thanks you for your suggestions or your advice of a tutorial that can help me to perform successfully this task.
    J.S.

    Writing to a file is pretty easy in Java. A simple way is to use the PrintStream class.import java.io.*;
    public class MyClass {
      public static void main(String[] arg) throws IOException {
        PrintStream ps=new PrintStream(new FileOutputStream(new File("someTextFile.txt")));
        //now use println(String) to write lines of text to the file
        ps.println("This is a line in the file");
        //always close the PrintStream when finished
        ps.close();
    }Alternatively, for a good tutorial, click the 'Tutorials' link in the left column on this page.

  • How to insert Newline in text file thr CL_ABAP_CHAR_UTILITIES

    Hi,
    I need to send a mail with TEXT file attachment which has many records in it. It is working fine. But the only problem is, all records are displayed in the 1st line itself. So i need to separate the records by inserting new line.
    constants: c_new type c value CL_ABAP_CHAR_UTILITIES=>NEWLINE.
    LOOP AT it_final INTO wa_final.
    lv_menge = wa_final-menge.
    CONCATENATE  wa_final-ebeln
               wa_final-bukrs
               wa_final-lifnr
               wa_final-ebelp
               wa_final-matnr
               wa_final-werks
               lv_menge
               c_new    " Newline
               INTO lv_txt SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    APPEND lv_txt to text.
    CLEAR: lv_txt, lv_menge.
    ENDLOOP.
    For this code, i'm not getting the new line for each record.
    Plz help me out for the same.
    Thanks,
    Ramesh

    Hi ,
    Sorry i cant get u.. Plz let me know exactly.. Now i replaced the Horizontal tab with CR_LF but even this is not working..
    CONSTANTS: c_new type ABAP_CR_LF value CL_ABAP_CHAR_UTILITIES=>CR_LF.
          LOOP AT it_final INTO wa_final.
            lv_menge = wa_final-menge.
            CONCATENATE wa_final-ebeln
                       wa_final-bukrs
                       wa_final-lifnr
                       wa_final-ebelp
                       wa_final-matnr
                       wa_final-werks
                       lv_menge
    "                   c_new
                       INTO lv_txt SEPARATED BY c_new. "cl_abap_char_utilities=>horizontal_tab.
            APPEND lv_txt TO text.
            CLEAR: lv_txt, lv_menge.
          ENDLOOP.
    Correct me if i'm wrong..
    Thanks
    Ramesh

  • Bulk Data - Insert / Update from text file - Urgent

    hi,
    Consider there is a Table A. There are around 1.7 Million
    Records.
    i have a situation that i will be getting the Data,
    Every two Weeks, around 100 - 200 thousand Records.
    I have to do some calculations.
    If any Old Data Exists, then update the Data
    for the Non - Primary Key Fields.
    Else
    I have to Insert the New Data.
    Most of the time, i will be getting update information.
    very few hundreds, insert records.
    Please, help me, by providing the techniques or tools.
    Is it posssible to automate the whole process.
    Sreedhar V
    null

    Sreedhar V (guest) wrote:
    : hi,
    : Consider there is a Table A. There are around 1.7 Million
    : Records.
    : i have a situation that i will be getting the Data,
    : Every two Weeks, around 100 - 200 thousand Records.
    : I have to do some calculations.
    : If any Old Data Exists, then update the Data
    : for the Non - Primary Key Fields.
    : Else
    : I have to Insert the New Data.
    : Most of the time, i will be getting update information.
    : very few hundreds, insert records.
    : Please, help me, by providing the techniques or tools.
    : Is it posssible to automate the whole process.
    : Sreedhar V
    Here's a process that might help:
    create a temporary table the same format as the flat file.
    create a sqlldr control file to load the data from the file into
    the temp table
    create a pl\sql or JAVA script to cursor through the records
    from the temp table and for each row see if there is a match on
    TABLE A. If so this is an update, if not it is an insert.
    If you are in a Unix environment you can write a shell script to
    automate the whole process and schedule it in kron.
    null

  • Cannot find symbol error -- array fill from text file

    When I compile my program I receive a cannot find symbol error for the variable ayears. I thought this snippet would fill the array ayears that could be accessed later in the program but I am getting the error message from my buildGUI() class. What could I have done wrong?
    (my file options.txt contains data separated by a comma and a space)
    public void getOption(){
         InputStream istream;
         File options = new File("options.txt");
         istream = new FileInputStream(options);
         try {
                               StringBuffer sbuff = new StringBuffer();
                               BufferedReader inbuff = new
    BufferedReader(new FileReader(options));
                               String line = "";
                               while((line = inbuff.readLine()) != null) {
                               System.out.println(line); 
              sbuff.append(line);
                               inbuff.close();
                              String fileData = sbuff.toString();
              String[] splitData = fileData.split(", ");
              String[] ayears = new String[splitData.length];
         catch(Exception e){
         JOptionPane.showMessageDialog(null,
         "Could not find specified file", "Error Message",
         JOptionPane.ERROR_MESSAGE);
    }

    Okay -- that helped. I've avoided that error -- now on to the next one, why won't my array fill? It's going to be a long night.
    Thanks for the help.

  • I need to insert Pages text file at end of a file; i.e., making one long document from several files. insert 'file' is not option in toolbar. how do i do this?

    i need to insert a Pages text file at end of another file; in other words, i'm making one long file from several files.  "insert file" is not an option in the toolbar, so how do i do this?

    cass516 wrote:
    this method sounds like a PAIN but of course i have no choice but to try it.  Why would Pages make such a simple thing so troublesome?  in other programs, you simply click 'insert file'.
    The only thing odd about Pages' Insert file is that it doesn't do its own format.
    You obviously think that MsWord is "The Norm" but I found really odd things that it won't do. To the point I, like others here, can't be bothered trying to drive the Word square peg into the Mac round hole.
    Mostly Pages works by drag and drop, I'm puzzled why that doesn't work with the thumbnails. But then there are quite a few oddities in every program. Pages is far from an exception.
    Peter

  • Export to text file shows extra character at line 60, 120 so on

    Hi,
    I am using Crystal report 13 with .net 4.0 ( Visual Studio 2010)
    I have an issue while exporting from CR to Text file,
    After every 60 lines some special character is inserted in the text file. That might be the new page character.
    Is this the limitation of crystal report that the data is not shown is pages?
    If yes, if there any workaround for this?
    Can I set the pagination off for the report- either from .net code OR on the report itself so that I wonu2019t see the unwanted character?

    [CR for VS 2010 .NET SDK developer guide|http://help.sap.com/businessobject/product_guides/sapCRVS2010/en/crnet_dg_2010_en.zip]
    [CR for VS 2010 API reference guide|http://help.sap.com/businessobject/product_guides/sapCRVS2010/en/crnet_api_2010_en.zip]
    See if this helps,
    Bhushan.

  • Write to text file; not overwriting old, but moving to next entry and writing

    I am interested in writing a series of filenames, to a text file, so I can keep track of sample ID and experiment #'s. I would like each new filename to be writtten following the previous filename, rather than always overwriting. I've done a brief check of some of the properties, and couldn't find anything. Any ideas? thanks

    Hey csmrunman,
     Just to clarify, are you looking to append text to an existing file without over-writing existing text, or are you looking to create a series of text files with unique names?  If you want to append text to an existing file, then Andrey's solution above should be what you need.  If you want to programmatically determine a unique name for the text files, then you can use a similar means to deterine a unique name (Andrey used the iteration terminal above so that each iteration of the while loop produces a unique text to be inserted into the text file).  You mentioned the use of sample ID and experiment number, which you could also use as a file name if you wish to, and even have the user of the VI enter the information that makes up the filename through front panel controls.  The string functions (in the Functions Palette under Programming » String) will be of great use here.  Of course, if you are just looking for an “out-of-the-box” solution, there is always the Write to Measurement File Express VI (Programming » File I/O), but this is best suited for situations where you have channels of data that you would like to store, so this may not fit depending on the data you wish to store.  If it does fit, however, there are settings that you can configure for saving to a series of files:
    Message Edited by Chris_G. on 09-28-2009 11:50 AM
    Chris_G
    Sr Test Engineer
    Medtronic, Inc.

  • Create text file in Database Trigger

    Hello,
    How to create text file in the database trigger. I am working on Row level trigger which has select statement if statement fails I have to create text file and insert record in text file. I tried to use file1 TEXT_IO.FILE_TYPE package it does not works.
    Thanks,
    Atif

    TEXT_IO is not available on the database. It is only available if you are doing client-side PL/SQL development in Oracle Forms. On the database side, you can use the UTL_FILE package.
    Since writing to a file is not transactional, however, and because Oracle may have to call a trigger multiple times to ensure write consistency:
    http://tkyte.blogspot.com/2005/09/part-iii-why-is-restart-important-to.html
    http://tkyte.blogspot.com/2005/08/part-ii-seeing-restart.html
    http://tkyte.blogspot.com/2005/08/something-different-part-i-of-iii.html
    you aregenerally better off not writing to a file in a trigger. The better answer is generally to use Oracle Asynchronous Queues to send a message to another process that actually writes the file. That way, if the transaction rolls back, nothing gets written to the file.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • How to get current month from filename and bulk insert from text file into table?

    I set up some dynamic SQL to help my bulk copy data from a text file to a table.  This works fine for files that come in every day; I get the previous day’s data, based on the file name that’s placed
    in the folder.  That’s why I’m using the ‘-1’.  The dates will look like this: '20140131', so I'm using type 112.
    declare @fullpath1 varchar(1000)
    select @fullpath1 = '''\\system.local\ms\london\FTP\' + convert(varchar, getdate()-1, 112) + '_INDEXPRICES_EOM.SPC'''
    declare @cmd1 nvarchar(1000)
    print (@cmd1)
    select @cmd1 = 'bulk insert [dbo].[SB_Monthly] from ' + @fullpath1 + ' with (FIELDTERMINATOR = ''\t'', FIRSTROW = 5, LASTROW = 675, ROWTERMINATOR=''0x0a'')'
    print(@cmd1)
    exec (@cmd1)
    I think the syntax will be somewhat similar to this:
    YEAR(date_column)=YEAR(getdate()) AND MONTH(date_column)=MONTH(getdate())
    I’m not totally sure how to incorporate that into my current syntax.
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

    I tried a couple versions of this.
    Declare @StartDate Date, @EndDate Date
    Select @StartDate = convert(varchar, getdate()-28, 112), @EndDate = convert(varchar, getdate()-1, 112)
    BEGIN
    declare @fullpath1 varchar(1000)
    select @fullpath1 = '''\\ms\london\FTP\' + ''' between ''' + Convert(Varchar(10), @StartDate, 101) + ''' and ''' + Convert(Varchar(10), @EndDate, 101) + '''_SP.SPC'''
    declare @cmd1 nvarchar(1000)
    print (@cmd1)
    select @cmd1 = 'bulk insert [dbo].[SPBMI_Monthly] from ' + @fullpath1 + ' with (FIELDTERMINATOR = ''\t'', FIRSTROW = 5, LASTROW = 675, ROWTERMINATOR=''0x0a'')'
    print(@cmd1)
    exec (@cmd1)
    END
    Here’s the string:
    bulk insert [dbo].[SPBMI_Monthly] from '\\ms\london\FTP\' between '02/03/2014' and '03/02/2014'_SP.SPC' with (FIELDTERMINATOR = '\t', FIRSTROW = 5, LASTROW = 675, ROWTERMINATOR='0x0a')
    The error message I keep getting is:
    Msg 156, Level 15, State 1, Line 1
    Incorrect syntax near the keyword 'between'.
    Msg 319, Level 15, State 1, Line 1
    Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.
    I feel like I’m already pushing this thing to the limit. 
    Maybe this last part isn’t possible.
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

  • Using servlets to read from text file and insert data

    Hi,
    Can I use a servlet to read from a space delimited text file on the client computer and use that data to insert into a table in my database? I want to make it easy for my users to upload their data without having to have them use SQL*Loader. If so can someone give me a hint as how to get started? I appreciate it.
    Thanks,
    Colby

    Create a page for the user to upload the file to your webserver and send a message (containing the file location) to a server app that will open the file, parse it, and insert it into your database. Make sure you secure the page.
    or
    Have the user paste the file into a simple web form that submits to a servlet that parses the data and inserts it into your db.

  • CLIENT_TEXT_IO : cannot insert new line into a text file

    Facts:
    Developer 10g
    AS 10g
    Web utility
    Problem:
    i am traying to
    Open a text file. using CLIENT_TEXT_IO.FOPEN
    insert a record in to a text file using CLIENT_TEXT_IO.PUTF
    insert a new line using chr(10) or CLIENT_TEXT_IO.NEW_LINE
    or CLIENT_TEXT_IO.put_line
    insert the next record
    Close the file.
    all work except insert a new line
    Why !!!
    it was Working fine in 6i, but now in 10g and Webutil is not working
    plz help

    Hi you can put a new line in a text file using System.getProperty("line.separator"). This implementation will work for every OS.
    import java.io.*;
    class Demo{
    public static void main(String args[]) throws Exception {
    FileWriter fr = new FileWriter("FileDemo.txt");
         fr.write("AAAAAAAAAA");
    fr.write(System.getProperty("line.separator"));
    fr.write("AAAAAAAAAAA");
    fr.close();
    }

  • How to insert data into the mysql table by giving as a text file

    Hi,
    Any one know's how to insert data into the mysql table by giving as a text file as the input in JSP.Please respond ASAP.
    Thanks:)

    At least you can try StringTokenizer to parse your text files. Or download a text JDBC driver to parse your files, for instance, HXTT Text(www.hxtt.net) or StelsCSV(www.csv-jdbc.com).

  • Filling an object ArrayList from a text file

    Hi all,
    I am developing a project (for university) which has a class named "SupplierAgent", which is required to keep database of custom objects of type "InventoryItem". Basically these consist of a String (for the name of the item), an int representing the quantity on hand, and an int representing the unit price (in cents). I wish to have this inventory loaded from a text file rather than a binary file - that way the user can add new items to the file before loading the agent.
    I have included the code below, which works provided the file is rigidly structured. The main problem is the user having to type the path to the file: I cannot guarantee the user will have the file in any folder, and so the user is required to type in the absolute path. Is there any way to make this less annoying? Or is there a better way of loading a preset inventory while allowing the user to edit that inventory at will?
    I have included the current code below. it's not exactly in accordance with coding standards, because we are using the JADE agent architecture (hence why the method is called "action") rather than something more informative.
    I should also mention that it uses a command line interface. The "io" class basically includes a scanner and the System.out.println method. Its "yesOrNo()" method is for convenience: it asks the user a question and allows them to select y or n.
    public void action() {
                boolean loadFromFile = io.yesOrNo("Would you like to load the inventory from a file?");
                if(loadFromFile) {
                    BufferedReader br = null;
                    boolean fileFound = false;
                    while(!fileFound) {
                        io.output("Please enter the absolute path to the file, including filename extension:  ");
                        inventoryFile = io.input();
                        try {
                            FileReader fr = new FileReader(inventoryFile);
                            br = new BufferedReader(fr);
                            fileFound = true;
                        catch (FileNotFoundException e) {
                            io.output("File not found.  ");
                    String fileLine = null;
                    int lineNumber = 1;
                    InventoryItem item = null;
                    try {
                        while((fileLine = br.readLine()) != null) {
                            switch((lineNumber % 4)) {
                            case 1: item = new InventoryItem();
                                    item.setName(fileLine); break;
                            case 2: item.setQuantity(Integer.parseInt(fileLine));
                            case 3: item.setPrice(Integer.parseInt(fileLine));
                            case 0: inventory.add(item);
                        io.output("Inventory loaded successfully\n");
                    catch(Exception e) {
                        io.output("Error at line " + lineNumber + " of inventory file\n");
                        io.output("Unable to fill inventory.  Please ensure file is structured correctly\n");
                        io.output("See readme for explanation of file structure requirements\n");
                        myAgent.doDelete();
            }Edited by: Swiftslide on Apr 22, 2010 6:34 PM

    You can use JFileChooser to allow the user to navigate to the required file.

Maybe you are looking for

  • New DC without netlogon share is not working.

    Hello all, I have a brand new DC  (server 2012) that I joined to my domain and it is not behaving. It is a clean install plus the directory services role, the static IP and the promotion, nothing else. The domain has one more DC (server 2012) and it

  • Two AlV Grids in a single screen

    I want to bring two ALV GRIDS in a single report output screen.How can i achieve this through Classical coding( not OBJECT ORIENTED ). If possible please provide with codes. thanks, Venkat

  • Error  in XML file while deploying in server

    Hi friends, I am Venkataramana . I am doing one small structs application with Validation . as usual in XML file i wrote validations but when i am deploying in server it is showing error as SEVERE: Parse Error at line 2 column 17: Document is invalid

  • Pages for iPad and iMac?

    I installed pages on my iPad Mini.  I am setting up a trip report template to use on an upcoming trip.  Thought it would be easier to set up on my iMac but realized that I might have to purchase Pages ($19.99) for iMac.  I have used Word (for iMac) f

  • Webservice ---- XI ------ .Bapi

    Hi Experts, Could anyone please explain the step by step procedure for the below scenario in XI. webservice <--> XI <----> .Bapi