Reading the data from 2 files and writing it into the 3rd file?

Hi,
I am reading datas from 2 files Say,
Example1.txt Example2.txt
Ashok ^data1^data2^data3
Babu ^data1^data2^data3
Chenthil ^data1^data2^data3
Danny ^data1^data2^data3
I want those data's to be written in a 3rd file. Say,
Example3.txt
Ashok^ data1^data2^data3
Babu^ data1^data2^data3
Chenthil^ data1^data2^data3
Danny^ data1^data2^data3
So that i can tokenize it with a delimeter(^) and get the values. Here how to append the datas in this form in Example3.txt. Eventhough u use FileWriter with append "true" as a parameter how they will apend like the Example3.txt file? Please do provide an answer for this..Since this is very urgent to be delivered...Expecting postive response.
Thanx,
JavaCrazyLover

import java.io.*;
import java.util.*;
public class en
public static void main(String args[]) throws IOException     
{int data,data1,offset,offset1;
          FileOutputStream fos1=new FileOutputStream("c:/example3.txt");
          FileInputStream fis=new FileInputStream("c:/example1.txt");
          FileInputStream fis1=new FileInputStream("c:/example2.txt");
while((data=fis.read())!=-1) 
     fos1.write(data);
while((data=fis1.read())!=-1) 
fos1.write(data);
fis.close();
fis1.close();
fos1.close();
}first create those 3 files in c:

Similar Messages

  • Read data from db and write it into the txt file

    hi all
    could anyone please help me regarding the following:
    i would like to read the data from database using sql query and the write the data into a text file.
    I am able to connect the db, run the query, create file...but not knowing how to write the data into the file.
    could anyone please help me out.
    thanks in advance
    regards
    sasasa
    Edited by: sasasa on Sep 14, 2009 8:57 AM

    i would like to read the data from database using sql query and the write the data into a text file.
    I am able to connect the db, run the query, create file...but not knowing how to write the data into the file.
    There must be something that I am missing.
    How is it possible to be able to navigate JDBC, run a query and create a file but not know how to write to it?

  • How can I input read a line from a file and output it into the screen?

    How can I input read a line from a file and output it into the screen?
    If I have a file contains html code and I only want the URL, for example, www24.brinkster.com how can I read that into the buffer and write the output into the screen that using Java?
    Any help will be appreciate!
    ======START FILE default.html ========
    <html>
    <body>
    <br><br>
    <center>
    <font size=4 face=arial color=#336699>
    <b>Welcome to a DerekTran's Website!</b><br>
    Underconstructions.... <br>
    </font> </center>
    <font size=3 face=arial color=black> <br>
    Hello,<br>
    <br>
    I've been using the PWS to run the website on NT workstation 4.0. It was working
    fine. <br>
    The URL should be as below: <br>
    http://127.0.0.1/index.htm or http://localhost/index.htm
    <p>And suddently, it stops working, it can't find the connection. I tried to figure
    out what's going on, but still <font color="#FF0000">NO CLUES</font>. Does anyone
    know what's going on? Please see the link for more.... I believe that I setup
    everything correctly and the bugs still flying in the server.... <br>
    Thank you for your help.</P>
    </font>
    <p><font size=3 face=arial color=black>PeerWebServer.doc
    <br>
    <p><font size=3 face=arial color=black>CannotFindServer.doc
    <br>
    <p><font size=3 face=arial color=black>HOSTS file is not found
    <br>
    <p><font size=3 face=arial color=black>LMHOSTS file
    <br>
    <p><font size=3 face=arial color=black>How to Setup PWS on NT
    <BR>
    <p><font size=3 face=arial color=black>Issdmin doc</BR>
    Please be patient while the document is download....</font>
    <font size=3 face=arial color=black><br>If you have any ideas please drop me a
    few words at [email protected] </font><br>
    <br>
    <br>
    </p>
    <p><!--#include file="Hits.asp"--> </p>
    </body>
    </html>
    ========= END OF FILE ===============

    Hi!
    This is a possible solution to your problem.
    import java.io.*;
    class AddressExtractor {
         public static void main(String args[]) throws IOException{
              //retrieve the commandline parameters
              String fileName = "default.html";
              if (args.length != 0)      fileName =args[0];
               else {
                   System.out.println("Usage : java AddressExtractor <htmlfile>");
                   System.exit(0);
              BufferedReader in = new BufferedReader(new FileReader(new File(fileName)));
              StreamTokenizer st = new StreamTokenizer(in);
              st.lowerCaseMode(true);
              st.wordChars('/','/'); //include '/' chars as part of token
              st.wordChars(':',':'); //include ':' chars as part of token
              st.quoteChar('\"'); //set the " quote char
              int i;
              while (st.ttype != StreamTokenizer.TT_EOF) {
                   i = st.nextToken();
                   if (st.ttype == StreamTokenizer.TT_WORD) {          
                        if (st.sval.equals("href")) {               
                             i = st.nextToken(); //the next token (assumed) is the  '=' sign
                             i = st.nextToken(); //then after it is the href value.               
                             getURL(st.sval); //retrieve address
              in.close();
         static void getURL(String s) {     
              //Check string if it has http:// and truncate if it does
              if (s.indexOf("http://") >  -1) {
                   s = s.substring(s.indexOf("http://") + 7, s.length());
              //check if not mailto: do not print otherwise
              if (s.indexOf("mailto:") != -1) return;
              //printout anything after http:// and the next '/'
              //if no '/' then print all
                   if (s.indexOf('/') > -1) {
                        System.out.println(s.substring(0, s.indexOf('/')));
                   } else System.out.println(s);
    }Hope this helps. I used static methods instead of encapsulating everyting into a class.

  • Get the data  from excel and insert into the database

    I want to read the data from excel file, get the data from excel and insert into the database.

    You can use the Apache POI HSSF API to read data from Excel files and you can use the Sun JDBC API to insert data in database.
    This has nothing to do with JSP/JSTL.

  • How to retrieve the data from Website and Upload it in SAP table?

    Dear ABAPers,
            I want to retrieve the data from website and upload the same in SAP Database Table is that possible.Please help me.It is very Urgent.
    Thanks & Regards,
    Ashok.

    Dear Abhishek,
                  Thanks for your reply.But my requirement is not met.
    If i execute the program it should retrieve the data from particular website.
    Thanks & Regards,
    Ashok.

  • When importing photos with iBooks Gallery widget, is anyone aware of a technique for simultaneously importing the photo's description (or jpeg file name) and writing it into the iBook Author caption field for the imported photo?

    When importing photos with the iBooks Author Gallery widget, is anyone aware of a technique for simultaneously importing the photo's description (or jpeg file name) and writing it into the iBook Author caption field for the corresponding imported photo? I have 4,800 stills to import and can't imagine it's necessary to copy and paste the description for each.

    As always, feel free to use the 'Provide iBooks Author Feedback' menu item for features you'd like added in the future, etc.
    http://www.apple.com/feedback/ibooks-author.html
    As for AS, I'm not sure anyone has sniffed iBA's dictionary yet...google is you friend for hot prospects, I'm sure

  • How to Extract Data from SAP and Load it into Essbase

    Hi All,
    Can you recommend some ways to extract data from SAP and load it into Essbase?. I have no knowledge about SAP, not sure how I can perform this task. Can I use ODI for this job?
    Thanks

    hi,
    Not sure if this helps but give a try
    you can create connection from EAS to SAP .. using a plug-in .. if you have access to oracle Support go for [ID 968961.1]
    or
    below are steps
    1. In EASPATH\console, open components.xml in a text editor.
    2. Under <PluginList>, enter <Plugin archiveName="SAP" packageName="com.essbase.eas.sap.ui"/> before the closing </PlugIn> tag.
    3. Save and close the file.
    4. In EASPATH\console\bin, open admincon.lax in a text editor.
    5. Search for lax.class.path= and append ;..\lib\sap_client.jar;..\lib \sap_common.jar to the entry. Save and close the file.
    6. In EASPATH\server\bin, open adminsvr.lax in a text editor.
    7. Search for lax.nl.java.option.additional, and append -DRFC_INI=EASPATH\server\saprfc.ini. Save and close the file.
    8. Create a new environment variable, RFC_INI, with a value of EASPATH\server\saprfc.ini
    9. Copy librfc.dll andsapjcorfc.dll to EASPATH\server\bin. You may need to obtain these files from SAP.
    let me know if it works :)

  • How can you pull in pdf's from iBooks and bring them into the Box app?

    How can you pull in pdf's from iBooks and bring them into the Box app?

    That sounds great, but I'm lost.
    I followed these steps:
    1) Open your PDF (in Adobe Acrobat Pro)
    2) Chose print
    The print/printer options pop-up will show.
    3) In the printer section, do not use your normal printer, a printer named Adobe PDF should be an option. Chose it.
    4) Under the "Page handling" section, change the Page Scaling drop-down menu to "Multiple pages per sheet".
    It works fine, but it looses all of the font information and the search no longer works. How can you do it and save the font info, so the search tool continues to operate.
    Am I missing anything?

  • On Adobe Acrobat Pro, how do I take a PDF file and convert it into an excel file?

    I am not sure how to take a PDF file and change it into an excel file. I have Adobe Acrobat Pro. Thanks!

    Using Acrobat XI Pro.
    File - Save As Other - Spreadsheet - Microsoft Excel Workbook
    Be well...

  • How to select the data from DB and write into File?

    Hi Experts,
    Can any one please help me,
    I want to write the data from a table "T1" from Data Base to one file in windows.
    This functionality i need to achive in SSIS package through script component and Execute SQL task if it's passible.
    If any other way is there please help me.

    through script component and Execute SQL task if it's passible
    The easier way is to use a "Data Flow" Task with a "OleDB Data Source" pointing the the SQL Server table / query and a "Flat File Destination" to export to a file.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Extract the data from database and send to XI in form of file

    hi,
        I am working on a scenario in which i am to extract thew data from an ODBC database. and send it to Integration Engine using a file adapter. In this case which adapter i should use? If i go for file adapter then how i will extract the data and if i go for JDBCadapter then i can't send the data in the form of file which is my basic requirement.
    Can someone help me out.

    Hi,
    You can Use JDBC Adapter to pull the data from Dbase very well.
    Check this For Refference Use
    PERIODIC SCHEDULING OF DATA BETWEEN ORACLE DB & R/3 SYSTEM
    Regards
    Seshagiri

  • [webdynpro] How to get the data from database and store in Excel sheet

    Hi All-
    I am developing an application in Webdynpro and I need to provide a URL ( link ) which if clicked , need to collect the data from Database ( SQL Server ) and puts in an Excel Sheet corresponding fields and opens the sheet.....
    Please look into this issue and help me out......
    Regards,
    Cris

    Hi Cris,
    Add-on to wat santosh has pointed to:
    Exporting table data to MS-Excel Sheet(enhanced Web Dynpro Binary Cache)
    (Or) If you have implemented your logic to get Database records below Blog should guide you in opening an excel with ur records.
    Exporting table data to MS-Excel Sheet(enhanced Web Dynpro Binary Cache)
    Regards,
    N.

  • Error in fetching the data from textfield and inserting to the database..

    I'm using Java Swing as front end and MySQL as backend using the netbeans ide..I am trying to fetch the data from the textfiled in the form and insert to the database table.i've skipped the generated code..In the following code i get the erro cannot find symbol "stmt" in the actionPerformed method..
    mport java.awt.event.*;
    import java.sql.*;
    public class BarcodeReader extends JFrame implements ActionListener {
    public BarcodeReader() {
    initComponents();
    nb.addActionListener(this);
    public void jdbcConnect(){
    Connection con=null;
    String url = "jdbc:mysql://localhost:3306/";
    String db = "mynewdatabase";
    String driver = "com.mysql.jdbc.Driver";
    String user = "usrname";
    String pass = "pwd";
    try{
    String s=newtxt.getText();
    con=DriverManager.getConnection(url + db, user, pass);
    Statement stmt=con.createStatement();
    Class.forName(driver);
    public void actionPerformed(ActionEvent e){
    try{
    jdbcConnect();
    stmt.executeUpdate("INSERT into machine(mname) values '"+jTextField1.getText()+"'");
    }}catch (Exception ex) {
    System.out.println(ex);
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new BarcodeReader().setVisible(true);
    }

    There are far too many errors to try and clear.
    For one, the exception references the actionPerformed method (according to your text), so why is that not shown here?
    For another you are performing, possible time-consuming, actions, and even worse IO actions, on the event thread, which is a huge no-no.
    You are not closeing your resources properly, if at all, which is another huge no-no.
    You are completely mixing your "view" (the gui), and your "model" (the data related classes), which is another huge no-no.
    etc, etc, etc.

  • Problem in Selecting the data from EKPO and KONV tables

    Hi Experts,
    Presently I am working on Report with Comparision-Sheet Between the vendor's Quotations. I have to display the Discount, Freight, Packing and Forwarding, Vat in Item level data based on the conditions made in PO.
    As per my Knowledge, Condition Types are stored in KONV Table. But there is no relation between KONV and EKPO tables.  So, I am unable to print the data for Discount, Freight, Packing and Forwarding, Vat... How can I get the values from EKPO and KONV tables?
    Thanks in Advance.
    Thanks n Regards,
    Muralikrishna.

    Don't recall if this is correct, but you may need the condition number from the header (EKKO) combined with EKPO-EBELP or other field as you key to access KONV (KNUMH and KPOSN).  My site doesn't run PP, so can't verify if the data is actually stored that, so just a possibility.

  • Export is not exporting the data from Page. It always gets the data from VO

    Hi,
    I have got a critical issue, where I am Not able to export the current data from the page.
    I have an export button and the VO is attached to it.
    1) My page will execute the VO and I do some calculations to remove some rows, add the grand total etc.
    2) The export button just re-executes the query and exports, which is not that, I want. I would like to export the current contents of the VO, which I manipulate and it is shown on the page.
    To give an example -
    My VO query is executed, when I click the Report button. I then adds Grand Total row to the VO and it gets displayed on the Page also.
    Now, when I click the export button, it just exports the data which is coming from the VO SQL query, whereas I want the data from current state of VO i.e. with the grand total, which I added and is coming on the page also.
    I will be really grateful, if someone can help me with this as it is really urgent.
    Thanks for your help.
    Shiju

    Hi Shiju,
    Is the export to csv opening fine with the data showing in individual columns when opening from internet explorer. What version of IE are you using? For us the export works fine from Firefox but does not work well in IE. From IE, the data shows with the commas in a single string. Appreciate your response as it will help us understand if our issue is local to our environment.
    Thanks.

Maybe you are looking for

  • DCGR in purchase order history

    Hi, I have created plant and testing stock transfer. But in sto purchase order history I don't see DCGR line item. I see GI, GR & DLnt. But I can't see DCGR. I don't understand  for what DCGR stands for. Alsow wnat to know the reason why it is not sh

  • Inserting MS WORD DOC into Oracle

    HI, Can someone help me in storing word document from local hard disk(windows C:\UploadFolder) into Oracle Table. I'm trying the following code: to create a directory---- create or replace directory MY_FILES as 'C:\Uploadfolder' table---- Create tabl

  • Problem with facebook publish

    I don't often publish to facebook, but in the past I have created several collections under the facebook publish service, each going to its own album of the same name. However today I decided to add 2 photos to an existing album, but when I click pub

  • User controlled execution

    Hey everyone. I'm very new to LabVIEW and it's my first post. So please excuse that I'm not familar with the boardsearch and my question has already been answered. I'm doing a vi with three sequences within a while-loop. The first one is used to coll

  • Security issue with NetStream.appendBytes() and BitmapData.draw()

    Iuse appendBytes to continuously and seamlessly stream video data into a netStream. since we're NOT playing the video files directly from a web domain, there is no meaning to the checkPolicyFile property of our netStream object and therefore - we can