Can't write to a file using File class

hi every body
I wanna write into a file for logging purpose, but I always
got an error when I write to the file ...
the code is:
if(!logFile.isOpen)
logFile.open("text", "write")
var date = new Date();
if(logFile.canWrite){
trace(">> I will write ...");
var message = "TIME >> " + date.getDate().toString() +
" : ERROR CODE >> " + infoObject.code + " : LINE NO >>
" + infoObject.lineno.toString();
logFile.write(message);
logFile.flush();
logFile.close();
I got an error says: File operation writeln failed
and also may say: File operation flush failed
thanx

First off, don't use finalize(). It is never guaranteed to actually run.
Just add a cleanup() method to your Account class that flushes and closes the writer; and call it before you exit main().
Now, as for your Date problem
java.util.Date certainly does have a no-args constructor.
java.sql.Date does not.
Make sure you aren't getting a name collision. (Hint: If you're doing import java.foo.* Stop Doing That. just import the classes you need)

Similar Messages

  • Can XSQL write to a file?

    Can XSQL write an XML fragment to a file?
    I've got this notion of writing an HTML form that posts to an XSQL Page, but in the event the database is down, I'd like to be able to save the state, to the user doesn't have to enter all the information again.
    null

    Custom action handler can certainly write to a file. You can use the getPostedDocument() method on the XSQLRequest that you have access to from within your action handler to get the posted XML document.

  • How can i write a XML file with oracle data ?

    How can i write a XML file using PL/SQL.
    Can i do as follows.
    1.Open a file using UTL_FILE.FOPEN(LC_DIR_LOC,'abc.xml','W')     ;
    2.write all the required tag and value using UTL.put_line
    that is enough. Is not, please guide me to write.
    gk

    Having Oracle 9i.
    One more doubt. In the speck, some constand values are there, When i write the same into file, How can i write ?.
    1. l_str := ' "E27" '
    or
    2. l_str := ' E27 '
    UTL_FILE.PUT_LINE(L_FILE_POI,l_str,TRUE);          
    1 case : in XML file : "E27"
    In 2 case : E27
    When we write a XML file through editors , we have to define the constant within quote . is it?      
    Which one can i use ? Or any other way is there ..
    Thanks and Regards
    gopi

  • How can i write the below code using "For all entries"

    Hi
    How can we write the below code using "for all entries" and need to avoid joins...
    Please help
    SELECT aaufnr aobjnr aauart atxjcd a~pspel
    agstrp awerks carbpl cwerks
    INTO TABLE t_caufv
    FROM caufv AS a
    INNER JOIN afih AS b
    ON aaufnr = baufnr
    INNER JOIN crhd AS c
    ON bgewrk = cobjid
    AND c~objty = 'D'
    WHERE ( a~pspel = space
    OR a~txjcd = space
    OR NOT a~objnr IN
    ( select OBJNR from COBRB AS e
    WHERE objnr = a~objnr ) )
    AND a~werks IN s_plant
    AND a~auart IN s_wtype
    AND NOT a~objnr IN
    ( select OBJNR from JEST AS d
    WHERE objnr = a~objnr
    AND ( dstat = 'A0081'OR dstat = 'A0018' )
    AND d~inact 'X' ).
    Reward points for all helpfull answers
    Thanks
    Ammi.

    Hi,
    SELECT objnr objid aufnr
            from afih
            into table t_afih.
    SELECT objnr
            from JEST
            into table t_JEST
            where stat = 'A0045'
               OR stat = 'A0046'
               AND inact 'X'.
    SELECT objnr
            from COBRB
            into table t_cobrb.
    SELECT arbpl werks objid objty
          from crhd
          INTO table it_crhd
          FOR ALL ENTRIES IN it_afih
          WHERE objty eq 'D'
          AND gewrk = it_afih-objid.
    SELECT aufnr objnr auart txjcd pspel gstrp werks aufnr
            FROM caufv
            INTO table t_caufv
            FOR ALL ENTRIES IN it_afih
            WHERE aufnr = it_afih-aufnr
              And pspel = ' '
              AND txjcd = ' '
             ANd objnr ne it_crhd-objnr
              AND auart in s_wtype
              AND werks in s_plant.
             AND objnr ne it_jest-objnr.
    dont use NE in the select statements, it may effect performance also. Instead use if statements inside
    loops.
    loop at t_caufv.
    read table it_chrd............
      if t_caufv-objnr ne it_chrd-objnr.
      read table it_jest..........
       if   if t_caufv-objnr ne it_jest-objnr.
        (proceed further).
       endif.
      endif.
    endloop.
    hope this helps.
    Reward if useful.
    Regards,
    Anu

  • Can a write-optimized DSO be used for Delta upload

    Hi,
    can any one please answer following..
    1. can a write optimized DSO be used for Delta upload?
    2. Does industry based content is available in BI Content ?
    Thanks&Regards
    Satya

    Hi,
    Write-Optimized DataStore does not support the image based delta, it supports request level delta, and you will get brand new delta request for each data load.
    Since write-optimized DataStore objects do not have a change log, the system does not create delta (in the sense of a before image and an after image). When you update data into the connected InfoProviders, the system only updates the requests that have not yet been posted.
    Write-Optimized Data Store supports request level delta. In order to capture before and after image delta, you must have to post latest request into further targets like Standard DataStore or Infocubes.

  • Can you write an avi file without using imaq

    Just curious if anybody has tried to write an avi file without using imaq vi's? So far I have only found sketchy info on the file format and am looking for some help on the file structure etc. Any references or example avi files with explanations of format would be most helpfull. Thanks in advance -

    Absolutely.......
    An AVI video file is actually structured in the same way as most Windows media files or RIFF files as they are generically known, thus the description below is applicable to for example WAV files etc.
    Thus the file always begins with the four byte code RIFF and continues to use this generic four byte coding known as FOURCC, four-character code or FCC throughout.
    There are then specific requirements for each different media content and the sections that must be included to define a valid file structure of the desired meadia type.
    Each section or 'CHUNK' is defined by an FCC (RIFF being the first) with facility to include additional FCC's as required. The FCC is followed by a length descriptor and then the data (just for fun the odd CHUNK does not quite fit this very general overview). These chunks then align to even word boundries so padding zeros are often inserted at the end of a CHUNK to make it all nice and neat.
    It is a requirement that software that does not recognise an additional custom CHUNK should ignore it, this is very easy as all you have to do is use the length descriptor to 'jump' over the CHUNK concerned.
    The following is an example from the 'CLOCK.AVI' found on windows computers for a number of years...
    RIFFjB AVI LISTΠhdrlavih8
    Here you can see the RIFF followed by a four byte length descriptor (4 Gigabytes), followed by various sub CHUNKS in this example the sub CHUNK is an AVI (note that it is actually 'AVI ' to conform to the FCC).
    So the CHUNK structure looks a bit like this:-
    RIFF ('AVI '
    LIST ('hdrl'
    'avih'()
    LIST ('strl'
    'strh'()
    'strf'()
    'strd'()
    'strn'()
    LIST ('movi'
    {SubChunk | LIST ('rec '
    SubChunk1
    SubChunk2
    ['idx1']
    For more information on all this you need to read the RIFF specification documentation on the MSDN website or on the MSDN Technet materials. Most of the stuff you will immediately locate will refer to the AVI file format as that is where most of the recent effort has been focused.

  • How can I write to a file from a livecycle designed PDF?

    I am producing a PDF in Livecycle designer and would like to write a sub-set of data from the document.
    I have tried methods such as exportData() but this exports everything which i don't need.
    I have seen another method which is to attach a file and write to that but ideally I'd just like to be able to create a new file.
    var data = xfa.data.nodes.item(0).nodes.item(1).saveXML()  var oFile = util.streamFromString(data , "utf-8");
    I would like to write oFile.
    Thanks in advance
    Edit:
    I would like to add that ideally the user would be presented with a save as dialog  box, so the can choose the location of where to save the xml data.

    an extraction out of expert one-on-one from Thomas Kyte
    <quote>
    when an oracle istance is created the services that support it are setup to 'log on as' the system (or operating system) account, this account has very few privileges and no acces to Window NT Domains. To access another Windows NT machine the OracleServiceXXXX must be setup to logon to the appropriate Windows NT Domain as a user who has acces to the required location for UTL_FILE.
    To change the default logon for the Oracle services go to (in Windows NT):
    Control Panel | Services | OracleServiceXXXX | startup | log on as; (where XXXX is the instance name)
    In Windows 2000, this would be:
    Control Panel | Administrative Tools | Services | OracleServiceXXX | Properties | Log on tab; (again XXXX is the instance name)
    Choose the This Account radio button, and then complete the appropriate domain login information. ONce the services have been setup as a user with the appropriate privileges, ther are two options dfor setting UTL_FILE_DIR:
    * Mapped Dirve: To use a mapped drive, the user that the service starts as must have setup a drive to match UTL_FILE_DIR and be logged onto the server when UTL_FILE is in use.
    * Universal Naming Convention: UNC is preferable to Mapped Drives because it does not require anyone to be logged on and utl_file_dir should be set to a name in the form \\<machine name>\<share name>\<path>
    You will of course need to stop and restart Oracle after changing the properties of the service.
    <\quote>
    I want to write some data to a (external) file. I have it working with the function UTL_FILE.
    My problem is I want to write to a file on a mapped drive (so a drive on a different machine). This is not working.
    Does anyone know a way to build this.
    Please send your responses to [email protected]
    Many thanks,
    Alex Nagtegaal

  • Writing to XP hosted drive- can't write a '.exe' file.

    I get this "The operation cannot be completed because you do not have sufficient privileges for some of the items" when I try to write a .exe file to a Windows XP shared volume.
    It creates the temporary file- (both ._filename.exe and filename.exe) but then presents the error message.
    I've disabled "simple file sharing" and given everything on the planet "Full Control" to the shared volume. I can write files, delete, create directories, dump them, whatever. I just can't do anything that involves modifying/writeing an .exe file.
    I can rename it to filename.e1xe and it goes.
    I've even disabled "OpLocks" (Opporunistic Locking) on XP.
    the file system is NTFS.
    The release notes for 10.4.6 said something about fixing this with similar issues, I've had this problem ever since Tiger. Using terminal gives me a permissions denied error too.

    Been there- done that, too. I should have mentioned it.
    The Windows Firewall - it's got an exception set for the local network and I even shut it off totally. McAfee got disabled too. One, the other and both at the same time. Same deal, no dice.
    Thanks for the thoughts thus far.
    Tony

  • Can you write an excel file on client machine instead of on the server

    I am trying to user cfSpreadSheet functon. The first question I have is, can you write the file on a client machine? I tried but they all end up on the server drive. Scecond question, is there a way to do row and column range formating in CF9.0? SpreadsheetFormatCellRange function is only available for ColdFusion server version 9.01.
    Thanks.

    To expand on Dan's answer: CF doesn't have any interaction with the client browser at all: client->server comms are handled by the client and the web server; the web server simply asks CF to provide the response data if the file requested is a CF file.  But even then all CF does is process the requested file and return data to the web server.
    Also, one of the restrictions of the HTTP protocol is that that there is *no* *way* that the server can write to the client machine.  All it can do is send data to the client agent (eg: a web browser) in response to the client agent requesting it.  Can you imagine the sort of security problems one would open one's self up to if a remote web server could write to your PC????
    Adam

  • How can I write to data file only near to SW Trigger samples?

    Hi everyone
    I am working on a model based in this one:
    http://zone.ni.com/devzone/cda/epd/p/id/34#0requir​ements
    I would like to save the data once the trigger is reached, with some data near to the impact.
    Where should I place a "write to measurement file" block in order to may load and plot the data of an impact test?
    Regards.
    Solved!
    Go to Solution.

    Celuti,
    You are so close!
    I am glad to see you understood what I recommended!
    You need to ensure that you connect the same data type to the Queue as what is coming from the DAQ.
    Please see the modified version of the code you posted.
    Craig
    CLD | CTD
    LabVIEW 2011 SP1 | TestStand 4.5
    Attachments:
    daqmx_sw_trigger_example (modified).zip ‏93 KB

  • How can i write a vi in using parallel port for digital inputs

    Dear all,
    i am a beginner user of LabVIEW and i want to write a vi in using parallel port for digital I/O. After reading the article "Using the Parallel Port in LabVIEW
    " and download the parallel.zip, i know how to write the vi for output, but i still don't know how to write the input one.i've try to use a Inport.vi to test, but nothing change when i set pin2-9 to high. (my computer:win2K & LabVIEW 6.1)
    Can anybody teach me how to write it?
    Can anyone write the vi for me too?
    Thanks all!
    p.s.i've already install the "accessHW.exe"

    Are you using VISA or the accessHW VIs? You may need to goto the bios and set the parallel port to run in spp mode or standard mode. This is the simpliest configuration and where you should start.
    As far as writing the VI goes, just copy the diagram out of the tutorial you mentioned.

  • Can I write with a stylus using  pages?

    I would like to know if I can write with a stylus using pages on my ipad. Has anyone been able to do this? thank you.

    The Pages app does not support a stylus pen.

  • How can I write to text file colorful texts

    I save system events in a text file,for example when system give warning message i want to write it red

    As others have mentioned, if you want to view text in different colors with an viewer/editor tool outside of LabVIEW, you must provide the necessary formatting for that tool.
    If it works for your application to view the file using LabVIEW you can do this:
    1) Place a unique key in each line that identifies an error.
    2) Display the text in a Listbox and color each line based on that unique key.
    You can fairly easily provide a stand alone viewer if needed.
    This technique can also be expanded to provide multiple colors.
    steve
    Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
    question. Give "Kudos" to replies that help.

  • Can i write information in file on trigger event.

    Dear Experts,
    I want ot store information in file on particular Trigger event.
    Is it possible? if yes then how?

    We can write to files using the UTL_FILE PL/SQL package. Please read the documentation on this: the security model in particular seems to trip up many newcomers.
    Cheers, APC

  • Can't Write to Program Files folder

    I am unable to copy files to the Program Files or Program Files (x86) folders, despite my status as Administrator on a single-user system. As an advanced user, I have many legitimate needs to place files there and cannot live with this level of protection
    from myself.
    How can I defeat this? Many thanks.
    Rick A.
    Pleasanton CA

    While I understand MS's position, they are unrealistic, and seems to be going the way of iOS by hiding the ability to do simple things.
    I can understand the need to set up an operating system for the masses (who don't understand computing concepts very well) so that it's more "idiot proof".  The problem is that people who don't fully understand what they're doing tinker around
    and destroy their ability to run Windows.  Or malware does it for them.
    And I don't think anyone ever said that the file system security setup - originally developed by Digital Equipment Corporation - is simple or easy to deal with.  I got training in it at a 1980 DEC conference that has proven oh so
    valuable in dealing with permissions issues over the decades.  It's funny the little things that prove useful in life.
    With suitable knowledge and reconfiguration (and even the application of 3rd party programs) the system CAN be made to be much more powerful FOR the (knowledgeable) user and less protected FROM the (knowledgeable) user.  This suits power-users.
    Some things said in this thread that are not accurate or are incompletely stated:
    ...you can't turn off UAC any more...
    Well, you CAN - through a registry modification - though because of Microsoft's decision to arbitrarily limit functionality this completely shuts out the possibility to run Metro/Modern apps.  For those who only need desktop functionality
    this isn't a bad thing.
    ...you should not use an administrator user for day to day tasks. it puts your system at risk..
    This is overgeneralized.  In terms of advice for everyday non-technical users, this may be reasonable, but there are cases where computer-knowledgeable people really do need to be able to do that to get all the productivity they can.  There
    are ways to insulate oneself from malware that are FAR better than inviting it into your system (IE runs ActiveX from the Internet Zone by default) then trying to block it at the last possible second.  Most people consider UAC prompts nothing more
    than irritating and just click through them as quickly as possible.  If avoiding malware is something you'd like to do,
    even if you'd prefer to continue to run with UAC enabled, I suggest taking the following three measures:  Get the
    hosts file from mvps.org, reconfigure Internet Explorer so as to not allow ActiveX to run from the Internet zone, and replace the out-of-box antivirus protection Microsoft provides with something better (e.g., Avast!).
    -Noel
    Detailed how-to in my eBooks:  
    Configure The Windows 7 "To Work" Options
    Configure The Windows 8 "To Work" Options

Maybe you are looking for