Append  new file to the old without reading the new file

Is there anyway to append a new file (new.txt) to the old file(old.txt) directly without using BufferedReader to read each line of the new.txt.?
Thank you very much for your input!

Look at RandomAccessFile, the length and seek methods.
If you're wanting better performance, you would need to test. I didn't check how the seek method positions to the specified location. If length() returns the EOF position, does seek() position directly to that location, or does it spin the file down from the start? And it very well might vary by os.
If anyone has additional information or can correct me, please do.

Similar Messages

  • Getting the size of a file without reading it

    Hello we are currently implementing a file upload/download framework in our application.
    The framework will included multiple filters such as for file mime types, suffices and size of the file.
    However, for the size filter, we want to check the size without reading it. This is because reading a file which we would later find unacceptable for our application would mean that we are wasting the resources. 
    Since we are currently using an IWDResource object to implement the framework, the method
             IWDResource.getStream(false).available()                                                                                may not come in handy as it seems to read the file to find out its size.
    I need to know whether there is some other method or approach we can emply, using IWDResource object, that will not read the file to find out the size.
    Thanks alot in advance.

    But, it doesn't give me an error, it just gives me the length of the URL, and for some reason it also adds 'D:\jsdk1.4\bin' to the beginning of my URL, so instead of
    File webFile = new File(webFileURL.toString());and you would think that it would be similar code to:
    File webFile = new File("http://66.185.95.103/8989898904/miko17a.avi");but instead, i've checked the File name, and it was
    D:/jsdk1.4/bin/http://66.185.95.103/8989898904/miko17a.avi
    or similar code...
    File webFile = new File("D:/jsdk1.4/bin/http://66.185.95.103/8989898904/miko17a.avi");why does it add the bin folder of my Java SDK to the beginning??? if it didn't do that, everything would be fine...

  • My MacBook Pro died, but have a TimeMachine backup. I've bought a new one. How do I make the new one just like the old without affecting the OS on the new one?

    My MacBook Pro died, but have a TimeMachine backup. I've bought a new one. How do I make the new one just like the old without affecting the OS on the new one?

    ppauley wrote:
    My MacBook Pro died, but have a TimeMachine backup. I've bought a new one. How do I make the new one just like the old without affecting the OS on the new one?
    One you start up the new one for the first time, Setup Assistant starts and offers you the option of migrating your old Mac to your new Mac with Time Machine, among other choices, as the source. You can also use Migration Assistant (in the Utilities Folder) to do the same thing.

  • With the new software for the I phone it appears 12 000 mails without reading and I can't find the solution, With the new software for the I phone it appears 12 000 mails without reading and I can't find the solution

    With the new software for the I phone it appears 12 000 mails without reading and I can't find the solution, With the new software for the I phone it appears 12 000 mails without reading and I can't find the solution

    Actually your suggestions are the ones that i have tried. i have seen that you have tried to help others with this issue and the only one that i could find that said they found the problem said that it was an ilife update issue and it fixed it and i have no available updates. i know it has to do with something in photo stream because it happens when i create a new library and it is loading the photos but i get the message before i reach the maximum 1000 photos. so i've tried updating, new library(first backing up photos and then deleting them from iPhoto), reinstalling OSX many times, running disc utilities. I called Apple the first day i had this issue and i was the first person to call them for support with the retina display and i actually had it escalated to a senior advisor and we thought we fixed the problem but we did not. i am pretty fluent in dealing with troubleshooting these type of issues and this is the first time i'm reaching out to the community. i figured now that the retina has been out some time now that there would be an obvious answer to this issue. thanks for the quick reply.
    Bebers5

  • How I can append new node in existing  XML file

    I've just begun learning DOM XML , so I'm currently at a very beginner level.
    I have an existing XML file that I would like to add an additional node to before saving it to another variable.
    how I can append new node in this file.
    now this code is overwrite new data over old data
    The code looks like this:
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.transform.Result;
    import javax.xml.transform.Source;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.TransformerFactoryConfigurationError;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    import org.w3c.dom.Attr;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    public class VerbXMLWriter
        static String EVerb3;
        static String englishTranslate3;
        public void VerbXMLWriter(String EVerb, String englishTranslate )
             EVerb3 = EVerb;
             englishTranslate3=englishTranslate;
        File xmlFile = new File("VerbDB.xml");
        DocumentBuilderFactory factory =  DocumentBuilderFactory.newInstance();
        try
         DocumentBuilder builder = factory.newDocumentBuilder();
         Document document = builder.newDocument();
        Element root = document.createElement("Verb");
         document.appendChild(root);
         Element verb = document.createElement(EVerb3);
         verb.setAttribute("EnglishTranslate",englishTranslate3);
         root.appendChild(verb);
         Source xmlSource = new DOMSource( document );
         Result result = new StreamResult( new FileOutputStream(xmlFile) );
        TransformerFactory transformerFactory = TransformerFactory.newInstance();
        Transformer transformer =
        transformerFactory.newTransformer();
        transformer.setOutputProperty( "indent", "yes" );
         transformer.transform( xmlSource, result );
      catch(TransformerFactoryConfigurationError factoryError )
        factoryError.printStackTrace();
       catch (ParserConfigurationException pc)
           pc.printStackTrace();
       catch (IOException io)
          io.printStackTrace();
       catch(Exception excep )
           excep.printStackTrace();
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <Verb>
    <Play EnglishTranslate="playing" />
    </Verb>Edited by: itb402 on Mar 9, 2008 6:05 AM

    in your code you are already appending new nodes to the root node. so what exactly is your problem? The following steps are usually taken for appending a new node:
    1. Read the XML document
    2. Build a DOM tree
    3. Navigate to the node under which you want to insert the new node
    4. Create a new node.
    5. Insert the new node to the node selected in point #3.
    ~Debopam

  • Why ehen appending text file to text area, all the text in 1 line..

    please hlp
          public void actionPerformed(ActionEvent e)
              TArea.setText("");
              try
              String StrNeeded;
              BufferedReader BR;
              BR=new BufferedReader(new InputStreamReader(new FileInputStream("Data.txt")));
              StrNeeded=BR.readLine();
                   while(StrNeeded!=null)
                   TArea.append(StrNeeded);
                   StrNeeded=BR.readLine();
              catch(Exception excep)
    }this is my code m problem is that,
    i read a text file that has many lines, when i read it, i append it into the textarea, but what happend was all the text in my text area is in 1 line only(the other line is also appended but it is appended in the sama line.. help me

    readLine removed the line feed from the end of the line.
    You should append a \n to the end of the line like this:TArea.append(StrNeeded + "\n");Also it's a bad idea to catch an exception and do nothing.
    Add printStackTrace in the catch block.

  • Append new records for a spool file

    Hello,
    I am running a query and sending the output to a spool file.
    The query never returns the same data because it is run every 2
    hours
    How can I make the spool to append the new records and not
    overwrite the old records?
    Thanks
    Carlos

    SPOOL.SPO[OL] [filename[.ext]|OFF|OUT]
    Oracle documentation provides no indication that any append
    functionality exists for the sql*plus command SPOOL.
    I can recommend two solutions:
    1. Spool to a temporary file in sql*plus, then perform a
    concatenation using the OS. Automate the process with a shell
    script (or batch file, as the case may be).
    2. Write the file using DBMS_OUTPUT.
    -Kevin

  • How do i sync up my old Adobe Reader files to Adobe Acrobat 10 that i just installed?

    Every old Adobe Reader file that i open doesnt automatically open as Adobe Pro, but as Adobe Reader. Is there a way to make all of these automatically merge to PRO? without opening them up in Adobe Pro one by one. Thank you.

    maybe deleting the reader from the computer? idk

  • Append a line at the beginning of a file via UTL_FILE

    Hello,
    is there a way to append a line to the beginning of a file instead of at the end of an existing file via UTL_FILE?
    Thanks in advance,
    Geert

    No, you would have to create a new file.

  • Reading, comparing and appending two files is taking lot of time

    public static void main(String args[])
         BufferedReader bSource = null;
         String sSource="";
         String sSourceData="";
         BufferedReader bDestination = null;
         String sDestination="";
         String sDestinationData="";
         try
              bSource = new BufferedReader(new FileReader("C:/TEMP/Source.map"));
              while((sSource = bSource.readLine()) != null)
                   sSourceData+=sSource;
              bDestination = new BufferedReader(new FileReader("D:/TEMP/Destination.map"));
              while((sDestination = bDestination.readLine()) != null)
                   sDestinationData+=sDestination;
         catch(IOException ioe)
              System.out.println(ioe.getMessage());
         finally
              try
                   bSource.close();
                   bDestination.close();
              catch(Exception e)
         if(sDestinationData.contains(sSourceData))
              fDestinationFlag=false;
         else
              fDestinationFlag=true;
         if(fDestinationFlag)
              BufferedReader br2 = null;
              BufferedWriter bw2 = null;
              try
                   br2 = new BufferedReader(new FileReader("C:/TEMP/Source.map"));     
                   bw2 = new BufferedWriter(new FileWriter("D:/TEMP/Destination.map",true));
                   while((line2 = br2.readLine()) != null)
                        bw2.write(line2);
                        bw2.newLine();
                        bw2.flush(); 
              catch(IOException ioe)
                   System.out.println(ioe.getMessage());
              finally
                   try
                        br2.close();
                   catch(Exception e)
                   try
                        bw2.close();
                   catch(Exception e)
    }I am comparing the contents of the two files Source.map (containing 3 lines) and Destination.map (containing 5000+ lines). The contents of the Source.map gets appended in the Destination.map only if it does not contain the same.
    Now my program is doing the necessary, but it is taking lot of time. It's taking 1 min 26 seconds.
    Could anyone please tell me what do I modify in may program to make it execute much faster.

    1) Just compare the byte content - no need to convert to Strings.
    2) Compare a block (say 256K bytes) at a time - no need to read the whole file into memory.
    3) Compare the file lengths first - if they are different then the content cannot be the same.
    4) When appending one file to the other, set the 'append' flag in the constructor of FileOutputStream to true.

  • Acrobat 9 Std-how to append new pages to existed/opened pdf file

    i am using Acrobat 9 standard version.
    when i used the scanner to create a pdf, but the file had many pages so i could not finish it before lunch. Therefore, i had to append new pages to the opened file.
    In past, 7 standard i could choose append to the opened file but 9 standard i don't have this function. Finally, i found the
    DOCUMENT / SCAN TO PDF / CUSTOM SCAN / TICK THE APPEND TO .....
    But, only 1 scan is allowed , what can i do now ????

    You can scan to different files, the you should be able to insert the
    second group of files into the first file using Documtent->Insert Pages.
    Mike

  • I need to know how to open the messages app without reading a message someone sent to me..

    I have my read receipts on because I like for people to know that I got their messages (most of the time).. But somebody texted me and I don't want to read their message. If I tap the messages app, then it will automatically pull that message up. Is there any way I can set my phone to where I can click the messages app to create a new message without reading the one this person sent to me?

    Turn off Send Read Receipts.  Then open the Messages app.

  • How to get server data without reading from the socket stream?

    My socket client checks for server messages through
                while (isRunning) { //listen for server events
                    try {
                            Object o = readObject(socket); //wait for server message
                                tellListeners(socket, o);
                    } catch (Exception e) {
                        System.err.println("ERROR SocketClient: "+e);
                        e.printStackTrace();
                    try { sleep(1000); } catch (InterruptedException ie) { /* ignore */ }
                }//next client connectionwith readObject() being
        public Object readObject(Socket socket) throws ClassNotFoundException, IOException {
            Object result = null;
    System.out.println("readObject("+socket+") ...");
            if (socket != null && socket.isConnected()) {
    //            ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
                ObjectInputStream ois = new ObjectInputStream(new DataInputStream(socket.getInputStream()));
                try {
                    result = ois.readObject();
                } finally {
    //                socket.shutdownInput(); //closing of ois also closes socket!
        //            try { ois.close(); } catch (IOException ioe) { /* ignore */ }
            return result;
        }//readObject()Why does ois.readObject() block? I get problems with this as the main while loop (above) calls readObject() as it's the only way to get server messages. But if i want to implement a synchronous call in adition to this asynchronous architecture (call listeners), the readObject() call of the synchronous method comes to late as readObject() call of the main loop got called before and therefore also gets the result of the (later) synchronous call.
    I tried fideling around with some state variables, but that's ugly and probably not thread safe. I'm looking for another solution to check messages from the server without reading data from the stream. is this possible?

    A quick fix:
    - Add a response code at the beginning of each message returned from the server indicating if the message is a synchronous response or a callback (asynch);
    - Read all messages returned from the server in one thread and copy callback messages in a calback message queue and the synch responses in an synch responses queue;
    - Modify your synchronous invocation to retrieve the response from the responses queue instead from the socket. Read the callback messages from the corresponding queue instead from the socket.
    Also take a look at my website. I'm implementing an upgraded version of this idea.
    Catalin Merfu
    High Performance Java Networking
    http://www.accendia.com

  • Append New Line Item(s) onto the created Purchase Request using Function

    Dear Expert,
    I am trying to append new lines into the created purchase request via Function Module/ BAPI.
    Say, now, the Purchase Request has already 1 line item. And i want to append new line items into
    this purchase request via function module/ bapi.
    Do you know if there is any function module/ bapi exists to do this?
    Thanks.
    Tee

    Hi,
    It's weird.
    I tried on the BAPI_PR_CHANGE, and the return message says that it has successfully changed the PR. But, when i see it via ME53N, it's not being updated.
    Does anyone has sample usage/ code using this BAPI?
    Thanks.
    Tee

  • My disc drive on my imac does not appear to be working. It takes the disc in but then spits it out without reading it. I have thought about purchasing an external disc drive, can someone advise me please?

    My disc drive on my imac does not appear to be working. It takes the disc in but then spits it out without reading it. I have thought about purchasing an external disc drive, can someone advise me please?

    Try the following:
    In Finder, select the problematic volume and then press command-I.
    Expand the Sharing & permissions section if it's collapsed.
    If the section is locked, then unlock it by pressing the padlock button and then authenticating as directed.
    Tick/check Ignore ownership on this volume.

Maybe you are looking for

  • Purchase order - Invoice cancellation

    Hi Guru's, 1.We have a PO with Header currency USD, Company code currency SGD, Exchange rate fixed is not ticked. 2. We created the invoices as follows Inv 1) 01.01.2007 - 100nos - 1000USD (loc cur val 1500SGD system calculated) Inv 2) 01.02.2007 - 1

  • How to add my drop down menu to my website

    I have been following a dreamweaver video to create a drop down menu with pure css which has turned out great.  My problem is when you follow a video I followed the instructions and started a new html and then attached the css styles to the new html

  • How do I RE-Configure Lion Server?

    So, i was playing with Lion Server, and had managed to Mail to recieve, but not send messages, and webmail sems to be all messed up. How do i Re-run the Configuration for  Lion server? It's a remote Mac Mini, so i am not able to be physically at the

  • REP-1212: Object  is not full enclosed by its eclosing object body

    hi am in oracle report 11gR2 am geting this error when running my report REP-1212: Object  is not full enclosed by its eclosing object body

  • DIsk verify/repair not working

    My computer seemed a bit slow and slightly erratic so it seemed time for a rerun of disk utility. Disk repair ran so far, then exited leaving an error message: 'The underlying task reported failure on exit'. I tried verify, then repair permissions, b