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.

Similar Messages

  • Insert a line into the beginning of a file without overwriting data

    I would like to dynamically alter/add new headers to a csv file as needed. The code I have below overwrites the previously written data an amount equal to each new header added each time I call the vi below. Any suggestions on how to do this without reading in the file each time? I want to avoid the processing time of reading in the file between processing new data.
    Thanks!
    Attachments:
    R900 - Log Data Stream to File.vi ‏22 KB

    Yes, but you can still write everytime, you dont need to read the file back.
    /Y
    LabVIEW 8.2 - 2014
    "Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
    G# - Free award winning reference based OOP for LV

  • Appending "something" at the beginning of a file

    Hello,
    I am trying to append a character to the beginning of a file, doesnt seem to work with RandomFileAccess. I first called the seek() methond
    seek(0); //zero to send the file pointer to the front 
    write((byte) myCharValue);apparently it overwrites the value at the front instead of adding for example:
    before running the code the file has: "Java is Cool!"
    after running the code the file has: "xava is Cool!"
    Any Ideas?
    Thanks

    1. Create a new file.
    2. Write out whatever you wanted to insert at the beginning.
    3. Copy the data from the old file and append it to the new file.
    4. Close the files.
    5. Delete the old file.
    6. Rename the new file.

  • How to remove characters/lines from the beginning of an InputStream

    Hi,
    I have a program which receives several InputStreams. From each of these streams I have to remove 2 lines from the beginning. After the lines are removed, all the streams are combined to one with SequenceInputStream and read in one chunk. Is there an easy/simple way of doing this?
    One option I thought would be to read the char by char until 2 end of line chars have been detected and then read the rest of the data to a buffer. And the create a ByteArrayInputStream out of this buffer. Problem with this approach is, that the amount of data can be large, so putting all the data in to memory might cause problems.
    Another option is to use BufferredInputStream and use the readline() method twice to get rid of the lines that are not needed. After this I would write the data to some output stream, which is then converted back to input stream. Propably would work, but sound too much of work for a simple thing like this. There has to be better way.
    To make it simple, what I need is a method that looks like the following, or something similar
    *  Removes n number of lines from the beginning of a InputStream.
    *  @param is InputStream where the lines are removed
    *  @param numberOfLines int value to indicate how many lines whould be removed
    *  @return InputStream where lines have been removed.
    public InputStream removeLines(InputStream is, numberOfLines);Thanks.

    Here's the code, feel free to use it. Comments are also welcome.
    public InputStream removeLinesFromTheBeginning(InputStream is, int numberOfLines) throws IOException
              char c = 'c';
              int i = 0;
              for(int n = 0 ; n < numberOfLines ; n++)
                   do
                        c = (char)is.read();
                        System.out.print(c);
                        if(c == (char)-1)     // end of stream reached before any newline characters were found.
                             return null;
                        i++;
                   while(c != '\n');
                   System.out.println();
                   System.out.println("Characters removed:" + i);
                   System.out.println("n: " + n);
                   i = 0;
              return is;
         }Edited by: dave_spaghetti on Jun 16, 2009 5:42 AM
    Fixed a bug.

  • Add a new line at the begining of a string in a Xquery ALSB3.0

    Has anyone figured out how to Add a new line at the begining of a string in a Xquery in ALSB3.0?
    Thanks for your Help.

    I believe this is related to BI Publisher. Any comments would be greatly appreciated.
    Thanks,
    Sinan

  • How would I erase the beginning of a file?

    I want to be able to erase the beginning of a file, while writing to the end...WITHOUT reading the whole file and writing it again because that would be a waste of resourses. Obviously I know that option is available.
    My situation is that I am adding lines to a log file, and I want to remove any entries that are X hours old. Logging a lot of information would mean that every few seconds, an entry is older than X hours and needs to be removed. It doesnt have a set number of lines so I can't just recycle the file by doing something like: if at line number Y, start at line 1 and remember the current line number.
    Adding to the top of the file, pushing the others lines down, and making cuts at the end would also work, but the same situation arises, how do I add to the beginning of the file, without having to copy the entire file to add the entry to the top.
    The reason I don't want to read the whole file is because having to read the whole file and write the whole file when an entry is made is time consuming and wastes CPU and memory, especially when the logs are coming in several lines a second.

    I would think it could easily be done. say you want to erase the first 10 bytes, why cant you just say move the start of the file up 10 bytes. Somewhere in the filesystem the start of the file is stored. I found underlying file copying that claims this in FileChannel's transferTo and transferFrom:
    This method is potentially much more efficient than a simple loop that reads from this channel and writes to the target channel. Many operating systems can transfer bytes directly from the filesystem cache to the target channel without actually copying them.
    If I can't just chop, I'll have to copy quickly at scheduled intervals.
    This is code I ran to test the above quote:
        public static void main(String[] args) throws Exception{
            args = new String[2];
            BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("Enter File Name:");
            args[0] = input.readLine();
            System.out.println("Enter test (0-2):");
            args[1] = input.readLine();
            long time = System.currentTimeMillis();
            int version = Integer.parseInt(args[1]);
            switch (version) {
                case 0:
                    BufferedReader in = new BufferedReader(new FileReader(args[0]));
                    PrintWriter out = new PrintWriter(new FileWriter("tempfile.txt"));
                    in.readLine();//skip line.
                    for (String line = in.readLine();line != null;line = in.readLine()) {
                        out.println(line);
                    in.close();
                    out.close();
                    break;
                case 1:
                    RandomAccessFile raf = new RandomAccessFile(args[0],"rw");
                    String line = raf.readLine();
                    long offset = raf.getFilePointer();
                    byte[] b = new byte[1024];
                    int bytes = 1024;
                    long index = 0;
                    System.out.println("index = " + raf.getFilePointer());
                    System.out.println("index = " + line.length());
                    while(bytes == 1024) {
                        bytes = raf.read(b);
                        index = raf.getFilePointer();
                        raf.seek(index - bytes - offset);
                        raf.write(b,0,bytes);
                        raf.seek(index);
                    raf.setLength(raf.length()-offset);
                    raf.close();
                    break;
                case 2:
                    RandomAccessFile raf2 = new RandomAccessFile(args[0],"rw");
                    String line2 = raf2.readLine();
                    long offset2 = raf2.getFilePointer();
                    FileChannel f = raf2.getChannel();
                    FileChannel g = f.position(0);
                    g.transferTo(offset2,raf2.length() - offset2,f);
                    raf2.setLength(raf2.length()-offset2);
                    raf2.close();
                    break;
            System.out.println(System.currentTimeMillis() - time);
        }and had these results
    166MB Log File
    Linux Mandrake 900Mhz
    Case 0 = 32914 ms
    Case 1 (1k byte[]) = 15043 ms
    Case 1 (16k byte[]) = 6988 ms
    Case 1 (1MB byte[] = 6113 ms
    Case 2 = 6188 ms
    :-/ guess this proves that the FileChannel can't chop

  • How to delete the beginning of a file?

    Hi,
    is there a way to delete the beginning of a file, or do I have to copy the rest of the file and create a new one and then delete the old one?
    Lets say my file contains "ThisIsMyFile" and I want to delete "This", so that my new file contains "IsMyFile", how can I do this?
    thanx

    You have to copy.

  • Appending a zero in the begining

    Hi All,
    I have a table1 with a field zip of varchar2 type
    The data now is as following.
    zip
    1123
    76668
    11423
    33174
    2169
    What I need to do is the zip should be 5 digits. So I need t0 change all four digits zip like this
    zip
    01123
    76668
    11423
    02169
    any Ideas?
    Thanks,
    G.

    Hi,
    Well, you can even concatenate a zero at the beginning as a where clause is used in the UPDATE statement which is restricting the update to happen on only those rows which are of 4 character length.
    But if you want to update all the rows with variable lengths then you LPAD will be more efficient.
    SQL> select zip, lpad(zip, 5, '0'), concat('0',zip) from zip_tab;
    ZIP   LPAD( CONCAT
    1     00001 01
    12    00012 012
    123   00123 0123
    1234  01234 01234
    12345 12345 012345Regards

  • How to add a new line at the end of eTEXT file

    Hi,
    I have modified the RTF template for the R12.1.3 Positive Pay File report (IBYPOS_PAY_en.rtf). Everything is good, except that the bank requires a "T" (Capital T) character in a new line at the end of the text file. Has any of you came across this before? How do I modify the template to achieve this?
    Thank you,
    Sinan Topuz

    I believe this is related to BI Publisher. Any comments would be greatly appreciated.
    Thanks,
    Sinan

  • When I upgraded to FF 3.6, the line in the FF header with file, edit, view, etc is no longer visible. What do i need to do to display this line?

    When FF starts, the file, edit, etc line is not displayed. What do I need to do to display this line?
    Bill
    == This happened ==
    Every time Firefox opened
    == I upgraded to FF 3.6

    '''''"...the file, edit, etc line is not displayed"''''': That's the Menu Bar; see below.
    <u>'''Can't see the Menu Bar'''</u> (File, Edit, View, History, Bookmarks, Tools, Help)?
    Turning the Menu Bar on and off is a new feature in version 3.6.
    ''(~~red:Linux & OSX see~~: [[Menu bar is missing]] )''
    <u>''Windows'' Method 1.</u> '''''Hold down''''' the key and press the following letters in this exact order: V T M then release the key
    <u>''Windows'' Method 2.</u> Tap once on the F10 key, while the Menu bar is visible, choose "View > Toolbars", click "Menu Bar" so that a check mark is placed next to Menu Bar
    <u>''Windows'' Method 3.</u> Tap once and release the key. The Menu Bar will be displayed; then choose ~~red:V~~iew > ~~red:T~~oolbars and click on ~~red:M~~enu Bar so that a check mark is placed next to Menu Bar
    The Menu Bar should now be displayed permanently, unless you turn it off again using View > Toolbars. Check mark = displayed, NO check mark = not displayed.
    See:
    http://support.mozilla.com/en-US/kb/Menu+bar+is+missing
    http://kb.mozillazine.org/Toolbar_customization#Restoring_missing_menu_or_other_toolbars
    <u>'''Navigation Toolbar, Bookmarks Toolbar and other Toolbars'''</u> under View > Toolbars. Clicking on one of them will place a check mark (display) or remove the check mark (not displayed).
    <u>'''To display the Status Bar'''</u>, View, then click Status bar to place a check mark (display) or remove the check mark (not displayed).
    <u>'''Full Screen mode'''</u>
    http://kb.mozillazine.org/Netbooks#Full_screen
    Also see:
    ''' [[Back and forward or other toolbar buttons are missing]]'''
    '''[[Navigation Toolbar items]]'''
    '''[http://support.mozilla.com/en-US/kb/How+to+customize+the+toolbar How to customize the toolbar]'''

  • Xtra character appearing at the begining of a file written by my java pgm

    Hi,
    I am trying to write an object to an output file (which is a HTML document). But when the object is written at the
    begining of the file the following character appears
    ' �� '
    Is there a way to supress this character when the file is written ?
    My java program is running in a Sun Solaris machine and the file is created in the same directory.
    Thanks
    Bala.

    You have to give a lot more info... Are you trying to
    write the object as an object (ie serialize it) or are you
    simply trying to write the contents (data held in) this
    object to an HTML file? Some code would help too.....
    If you are simply wanting the contents written
    be sure you are not trying to use an ObjectOutputStream...
    If you are trying to write the Object (ie serialize it) then
    you have to remember that there are chances of
    non-printable characters being written...

  • Write filename to the beginning of that file.

    I need help on the following:
    While reading and validating a file in Java, HOW can I
    1. GRAB the FILENAME of the file I received,
    2. Open the file and WRITE the FILENAME at the BEGINNING of the file?
    Thank you in advanced.

    You can get the filename by using java.io.File.getName();
    As far as sticking it into the front of your file, you should read the whole old file (hopefully it's not too big), then write it all back out again to the same file, only write the name string first

  • Print data to the beginning of a file

    Hi,
    I have written this code to wite data to a textfile:
    PrintWriter FeedStream = new PrintWriter(new FileOutputStream(feed_path, true));
    FeedStream.println(text);
    FeedStream.close();The code works fine but it writes the data at the end of the file whereas I want it at the beginning of the file. How to solve this?
    Thanks in advance,
    leonard

    Well, the reason is that I want to print the data in another application and saving the data this way is more convenient.
    E.g.
    application 1 prints this to a file:
    L1 Test=45
    L2 Temp=10
    then the same application maybe has to write more data to the file at another time, and adding:
    L1 Test=39
    L2 Temp=12
    However application 2 that monitors the file every 6h should analyse the data from the newst to the oldest. For the conveniance when parsing the file with application 2 I want to add the data to the beginning of the file.

  • Read the content of a file (via socket)

    Hi,
    I need to read the content of a file (.txt, or better, .jpg) and to write it again in another file.
    I have this code (in Javascript):
        conn = new Socket;
        conn.encoding = "BINARY";
        if (conn.open ("127.0.0.1:8888")) {
        conn.timeout=30;
        conn.writeln("GET variousFiles/file.jpg HTTP/1.1");
        reply = conn.read(999999);
        conn.close();
        var file = new File("C:/APPS/New_File.txt");
        file.encoding = 'BINARY';
        var open_file = file.open("w+");
        file.write(reply);
        } else { alert("Errore: " + conn2.error); }
    However my new file is always empty, because I can not read the content of the first file.
    My variable "reply" is always empty.
    Thanks and best regards.

    There is a particular case with sugested function, if content is generated on the fly by the server -php, cgi, etc.-
    In this case, http server doesn´t knows total size of response data, so response shows a chunked transfer-encoding header and data is parted in chunks, each one starting with it´s size, and following the data.
    HTTP/1.1 200 OK
    Date: Tue, 30 Apr 2013 12:43:41 GMT
    Server: Apache/1.3.31 (Win32) mod_fastcgi/2.4.1
    Connection: close
    Transfer-Encoding: chunked
    Content-Type: image/jpeg
    f49
    ÿØÿà  JFIF
    I´m using this function to decode parted response, with initial chunkedString with firs chunk size; in this case, f49:
    PartsSeparator="\r\n";
    function getPartedBody(partedBodyString) {
        var separatorPosition=partedBodyString.indexOf(PartsSeparator);
        var chunkSize=new Number("0x"+partedBodyString.substring(0,separatorPosition));
        separatorPosition+=PartsSeparator.length;
        var bodyString=new String("BINARY");
        bodyString="";
        if (chunkSize>0)
            bodyString=partedBodyString.substring(separatorPosition,separatorPosition+chunkSize)+
                getChunkedResponse(partedBodyString.substring(separatorPosition+chunkSize+PartsSeparator. length));
        return bodyString;
    Hope this helps
    regards

  • PI731: FTP-FCC-Receiver with blank line at the beginning

    Hi,
    In my example I always get first a blank line but I do not want this blank line.
    I need the field FILENAME only as a variable name for the file name schema.
    Mapping:
    Communication Channel (Receiver / FTP / File Content Conversion)
    Result (with blank line)
    How can I solve my problem? Do I need to adjust the content conversion.
    Thanks
    Rene

    Hi René,
    Here is your solution..Variable substitution in case of non-XML target files in a multi-mapping scenario
    You just need to follow the adapter configuration.
    Cheers,
    Ambrish

Maybe you are looking for

  • Problem with Cisco IPMA - between the manager profile and assistant profile

    Greetings to all. The problem basically is that wen I do a call (internal o external) to the extension configured in the manager phone, the assistant phone dosen`t rings or take the call, even the call in progress dosen`t appears in the Cisco Unified

  • Converting Time Machine back into an External Hard Drive?

    before i got my macbook, i used my 320GB external hard drive on a windows XP-run computer. i transferred all my files to my new mac, before using it as my time machine drive. it's now incompatible with windows though. is there any way to either -allo

  • Best Extention / Plug-in for Lightbox/Shadowbox

    Basic question here... We are looking for the best (easy) DW extension / plugin to display our galleries and movies on our website in the Lightbox/shadowbox style - there are **so many option** so we thought we'd come to the source and get the latest

  • Replicat goes down. when new table added to source

    Hi I am using a 10gR2 setup on Linux (using em's) and then a 11g. I have a goldengate setup. Everything seems to be working fine except when we add a table at the source it doesn't get replicated on the target? and the replicat gets abbened-ed when r

  • Scheduled GridControl jobs get not executed

    Hello, I have a really strange behaviour lately with the GridControl jobs: We have several GridControl jobs which are scheduled (e.g. from monday til friday at 05:00 am). In usual, they get executed at the scheduled time. But some of them don't get e