BufferedWriter(Writer out)  and flush()

BufferedWriter(Writer out)
correct me if i'm wrong, but when i use BufferedWriter(Writer out) as in
pout = new PrintWriter(new BufferedWriter(new FileWriter("log.txt");
i do not have to call flush().
it will automatically call flush when the buffer is 512 is that correct ?
or do i have to still call flush to make sure the contents come out.
Stephen

I'm using jav 1.4.
Notice the code below:
I get a null exception when trying to write() a second time with the PrintWriter instance .
Here is the error
Tracer constructor works
getLogFileDate() = Jun-14--2002-8.17.42-AM
getLogFileDate() = Jun-14--2002-8.17.42-AM
main method starts
main method successfully gets Tracer instance tt. com.myinteractivesite.Tracer@888759
Exception in thread "main" java.lang.NullPointerException
at com.myinteractivesite.Tracer.log(Tracer.java:29)
at com.myinteractivesite.Tracer.main(Tracer.java:72)
Why do I get this null exception when trying to write a second time using the printwriter in the log() method ?
* Tracer.class logs items according to the following criteria:
* @since June 2002
import java.io.*;
import java.net.*;
import java.util.*;
import java.text.*;
class Tracer{
     public static void log(int traceLevel, String message, Object value)
          pout.write(getLogFileDate(new Date()) +" >" + message + " value = " + value.toString());
     public static void log(int traceLevel, String message )
          pout.write("HI HOW ARE YOU " ) ;
          pout.flush();
     //public static accessor method
     public static Tracer getTracerInstance()
          return tracerInstance;
     private static String getLogFileDate(Date d )
          String s = df.format(d);
          String s1= s.replace(',','-');
          String s2= s1.replace(' ','-');
          String s3= s2.replace(':','.');
          System.out.println("getLogFileDate() = " + s3 ) ;
          return s3;
     //private instance
     private Tracer(){
          System.out.println("Tracer constructor works");
          df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
          date                    = new java.util.Date();
          try{
          pout = new PrintWriter(new BufferedWriter(new FileWriter("Crawler_log"+getLogFileDate(new Date())+".txt", true)));
          pout.write("**************** New Log File Created "+ getLogFileDate(new Date()) +"****************");
          pout.flush();
          }catch (IOException e){
          System.out.println("**********THERE WAS A CRITICAL ERROR GETTING TRACER SINGLETON INITIALIZED. APPLICATION WILL STOP EXECUTION. ******* ");
     public static void main(String[] argz){
     System.out.println("main method starts ");
     Tracer tt = Tracer.getTracerInstance();
     System.out.println("main method successfully gets Tracer instance tt. "+ tt.toString());
     //the next method is where it fails - on pout.write() of log method. Why ?
     tt.log(1, "HIGH PRIORITY");
     System.out.println("main method ends ");
     //private static reference
     private static Tracer tracerInstance = new Tracer();
     private static Date date     = null;
     private static PrintWriter pout = null;
     public static DateFormat df = null;
}

Similar Messages

  • Just finished using iTunes, closed out and then tried to get back in.  Got this message "he iTunes library .itl file is locked, on a locked disk, or you do not have write permission for this file."  How can I get back into iTunes ?

    I just finished using iTunes, closed out and then tried to get ack in.  Got this message "The iTunes library .9tl file is locked, on a locked disk, or you do not have write permission for this file."   How can I get back ino iTunes ?

    I actually figured it out...I had to go to the iTunes Library Extras.itdb file and give myself permission to have full control.  THEN, I could go and estore a previos version.  Once I had done this, I got the same message for iTunes Library Genius.itdb . . . I did the same thing with it and Voila'!!
    Hope this helps...
    SVT

  • OSB logging - Process writes logs in both osb_server1.out and log file ..?

    Hello,
    I have few OSB proxy service and we have configured few log operations for logging but while testing, I noticed logs are getting written in both osb_server1.out and osb_server1.log file. I dont want to write logs in osb_server1.out file.
    I am running my weblogic server in development mode.
    Could someone please advice me whats wrong I am doing here.

    Hello,
    I have few OSB proxy service and we have configured few log operations for logging but while testing, I noticed logs are getting written in both osb_server1.out and osb_server1.log file. I dont want to write logs in osb_server1.out file.
    I am running my weblogic server in development mode.
    Could someone please advice me whats wrong I am doing here.

  • /n and /r is writting out as []

    I think this has something to do with the method of writting I am using
    i grab some information from a text field, add it to a string, but when I open it with notepad /n and /r look like [], (my other data does not look like this when I open it with notepad)
         String a=jTextField11.getText();
         String person = a + "\n xxx" + "\r"; 
         OutputStreamWriter out2 = new OutputStreamWriter(new FileOutputStream(Loc),"UTF-8");
         out2.write(person);
         out2.close(); What should be the method of witting that would prevent this?
    Edited by: Mr_Tuition on Dec 14, 2007 3:24 AM
    Edited by: Mr_Tuition on Dec 14, 2007 3:26 AM

    If I ask fred what colour it is and hes says red... Its red
    If he gives it to me, I play with it, then I give it back, then he tells me its blue, Its not fred thats at fault but me for playing with it.
    This data will be passed to 3rd party apps, and content editors. If manual content editors open this with note pad (which they will), they will not be happy when the see [][][][][], this is not the format they have used in the past, my app is supposed to help not hinder, I do not wish to restrict the content editors. There must be a method of witting that will write /n and /r out to files so that note pad interprets correctly.
    I know this is so, since if I read /n from a file then write it out, it displays correctly... so it must be the method of adding /n and /r to a string that is at fault, how can I then add them to display correctly in notepad
    Edited by: Mr_Tuition on Dec 14, 2007 3:50 AM
    Edited by: Mr_Tuition on Dec 14, 2007 3:52 AM

  • I dont know why, but my Messages wont work on my Macbook any more. It has signed me out and will not allow me to sing back in. Any ideas?

    Recently, my Messages app automatically signed me out and will not let me sign in again. I have tried everything. I can no longer send Imessages using my Macbook. How do I reset this thing?

    This could be a complicated problem to solve, as there are many possible causes for it. Test after taking each of the following steps that you haven't already tried. Back up all data before making any changes.
    Before proceeding, test on another network, if possible. That could be a public Wi-Fi hotspot, if your computer is portable, or a cellular network if you have a mobile device that can share its Internet connection. If you find that iMessage works on the other network, the problem is in your network or at your ISP, not in your computer.
    Step 1
    Check the status of the service. If the service is down, wait tor it to come back up. There may be a localized outage, even if the status indicator is green.
    Step 2
    Sign out of iMessage on all your Apple devices. Log out and log back in. Try again to sign in.
    Step 3
    Restart your broadband device and your router, if different. You may have to skip this step if you don't control those devices.
    Step 4
    From the menu bar, select
     ▹ About This Mac
    Below the "OS X" legend in the window that opens, the OS version appears. Click the version line twice to display the serial number. If the number is missing or invalid according to this web form, take the machine to an Apple Store or other authorized service center to have the problem corrected.
    Step 5
    Take the steps suggested in this support article. If you don't understand some of the steps or can't carry them out, ask for guidance.
    Step 6
    From the menu bar, select
     ▹ System Preferences ▹ Network
    If the preference pane is locked, click the lock icon in the lower left corner and enter your password to unlock it. Then click the Advanced button and select the Proxies tab. If the box marked SOCKS Proxy is checked, uncheck it. You don’t need to change any other settings in the window. Click OK and then Apply. Test.
    The result may be that you can't connect to the Internet at all. Revert the change if that happens, or if iMessage still doesn't work. Remember that you must Apply any changes you make in the preference pane before they take effect.
    Step 7
    Select from the menu bar
     ▹ System Preferences… ▹ Flash Player ▹ Storage
    and click
    Block all sites from storing information on this computer
    Close the preference pane.
    Step 8
    Make sure you know the ID and password you use with iMessage. Launch the Keychain Access application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Keychain Access in the icon grid.
    Use the search box in the toolbar of the Keychain Access window to find and delete all items with "iMessage" in the name. Log out and log back in.
    Step 9
    Enable guest logins* and log in as Guest. Don't use the Safari-only “Guest User” login created by “Find My Mac.”
    While logged in as Guest, you won’t have access to any of your personal files or settings. Applications will behave as if you were running them for the first time. Don’t be alarmed by this; it’s normal. If you need any passwords or other personal data in order to complete the test, memorize, print, or write them down before you begin.
    Test while logged in as Guest. After testing, log out of the guest account and, in your own account, disable it if you wish. Any files you created in the guest account will be deleted automatically when you log out of it.
    *Note: If you’ve activated “Find My Mac” or FileVault, then you can’t enable the Guest account. The “Guest User” login created by “Find My Mac” is not the same. Create a new account in which to test, and delete it, including its home folder, after testing.
    If iMessage worked in the guest account, stop here and post your results.
    Step 10
    Boot in safe mode and log in. Note: If FileVault is enabled on some models, or if a firmware password is set, or if the boot volume is a software RAID, you can’t do this. Ask for further instructions.
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including Wi-Fi on certain iMacs.  The next normal boot may also be somewhat slow.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    Test while in safe mode. After testing, reboot as usual (i.e., not in safe mode) and test again.
    If iMessage worked in safe mode, but didn't work when you booted out of safe mode, stop here and post your results.
    Step 11
    Reset the NVRAM.
    Step 12
    Reinstall OS X.
    Step 13
    If none of the above steps resolves the issue, make a "Genius" appointment at an Apple Store, or contact Apple Support.

  • How to hide check-in, check-out and publish buttons

    hi,
    i am new here and hope someone can help me:
    users of a community can edit some content items. they can open these items with this link (from administrators guide for al interaction publisher 6.5 p. 10-28):
    </pcs:value>/published_tools/content_item.jsp?&view=submit&ciid=<pcs:value expr="pcs_id"></pcs:value>" target="_blank"></a>
    the link works, users can edit the items.
    problem is, that i do not want to show the "publish button" to the users. the content item should be published automaticaly after the user clicks on "save". i also do not want users to see the check-in, check-out and preview buttons. they should just open a content item (+ simultaneously check-out), edit it and save it (+ simultaneously check-in and publish and close the content editor).
    i thought this can be done by the "view" parameter, but nothing happens if i use it. any ideas?
    thx
    volker
    Edited by: vhspec on 03.06.2009 00:58

    Hi vhspec,
    This is a common problem. A creative way to solve the problem is to point yourself to the description field of each input on a data entry template. When you have the need to make any dynamic changes to the entry templates simply drop some javascript into the description field of an input and write the appropriate javascript code to either hide buttons, change behaviour etc. When the data entry template is displayed to a user the javascript in the description field will be executed by the browsing. Fortunately publisher does not check the description fields or encode them so you can get away with a lot.
    The only problem with this approach is while you are altering the UI the underlying data model will still allow users to publish. So if an unauthorised user saw fit, they could publish content.
    Have you considered creating a workflow so that users in specific groups cannot publish? that way only a controller down the line would be able to approve and publish.
    Edited by: user8023716 on Jun 9, 2009 2:55 AM

  • I transferred all my Itunes music from an old PC to my new one with Windows 7.  Now I cannot edit "artist" or anything else for the songs.  It is all greyed out and I cannot enter information. Is there any way to correct this problem?

    I transferred all of my music from an older PC to my new one with Windows 7.  Now I cannot edit selected songs.  The information is greyed out and I can't type over it (on all my music except NEW downloads).  Can anyone help?  I even have a few songs with NO artist tag and I can't write anything in them either.

    It's a permissions problem. Try this: right click on your iTunes icon and choose "run as administrator" that might fix it.

  • [Flat File Destination [220]] Error: Failed to write out column name for column "Column 2"

    I am using SSIS to extract fixed width data into a flat file destination and I keep getting below error. I have tried almost everything in this forum but still no solution. can anyone help me out to solve this problem.
    [Flat File Destination [220]] Error: Failed to write out column name for column "Column 2".
    [SSIS.Pipeline] Error: component "Flat File Destination" (220) failed the pre-execute phase and returned error code 0xC0202095
    Thanks

    Hi Giss68,
    Could you check the Advanced tab of the Flat File Connection Manager to see whether the InputColumnWidth and the OutputColumnWidth properties of the Column2 has the same value? Please refer to the following link about the same topic:
    http://stackoverflow.com/questions/10292091/how-do-i-fix-failed-to-write-error-while-exporting-data-to-ragged-right-flat-fil 
    If it doesn’t work, please post the sample data and the advanced settings of Column2 for further analysis.
    Regards,
    Mike Yin
    If you have any feedback on our support, please click
    here
    Mike Yin
    TechNet Community Support

  • System.out and System.err

    Hi all,
    This is a stupid newbie question, but I could not find the answer on the Web
    site, so here goes: Where do System.out and System.err get written to? I'm
    trying to deploy some plain-vanilla stateless session beans that do a bunch
    of println() calls, but I can't see the output anywhere! The WebLogic
    Console shows no messages, /myserver/weblogic.log has nothing interesting,
    and there are no .log files anywhere that I can see. I even searched /tmp
    and found nothing of interest. What am I missing? Do I have to explicitly
    open a file for System.out and/or System.err? That doesn't sound right...
    - danz

    The simple answer to your questions are no and no.
    I recently logged a problem with BEA WebLogic technical support regarding
    this issue and their response is:
    You have two choices. You can either use standard Java file i/o to write
    your output to a file, or you can use our t3loggingservices to append
    messages into the weblogic.log
    The "jump point" for the logging services is at --
    http://www.weblogic.com/docs51/classdocs/javadocs/weblogic/common/LogService
    sDef.html
    It is actually very easy to use -- after you import the proper packages into
    your web application it is just as easy to use as System.out.println.
    John J. Feigal Voice (651)766-8787 (main)
    Sr. Technical Consultant (651)766-7249 (direct)
    Ensodex, Inc. Fax (651)766-8792
    4105 N. Lexington Ave., Suite 150 email [email protected]
    Arden Hills, MN 55126 WebSite http://www.ensodex.com
    "Jon Wynett" <[email protected]> wrote in message
    news:[email protected]...
    I'm running WebLogic as an NT Service. Is there any way to see the
    System.out.println messages? Can they be redirected to the weblogic.log
    file?
    We were running through a DOS Window and saw all the messages, however we
    ideally want to run Weblogic as a service.
    "Rob Woollen" <[email protected]> wrote in message
    news:[email protected]...
    I'm guessing that you started the server with the .exe file on Windows.
    If you're debugging with printlns, it's generally more conventient to
    use the startWebLogic.sh or startWebLogic.cmd files to start the server
    from a shell.
    By default, you'll see stdout and stderr in the window.
    -- Rob
    Dan Zivkovic wrote:
    Hi all,
    This is a stupid newbie question, but I could not find the answer on
    the
    Web
    site, so here goes: Where do System.out and System.err get written to?I'm
    trying to deploy some plain-vanilla stateless session beans that do abunch
    of println() calls, but I can't see the output anywhere! The WebLogic
    Console shows no messages, /myserver/weblogic.log has nothinginteresting,
    and there are no .log files anywhere that I can see. I even searched/tmp
    and found nothing of interest. What am I missing? Do I have toexplicitly
    open a file for System.out and/or System.err? That doesn't soundright...
    - danz

  • Multiple inner joins combined with outer and right.

    Hello
    Can someone give me an example of multiple inner joins?
    Meaning inner join on more than 3 tables. Can someone provide me sql statement that would be great?
    Also can you combine inner outer and right in one query if so how? Again, can someone provide me sql statement that would be great?
    Thank you so much

    You can look at my sample Re: Need Assistance to write a procedure for the below requirements!!!
    John

  • When starting Final Cut Pro 7.0.3 I am all of a sudden getting a message that says "One or more of the scratch disks don't have read/ write access" and now the app won't operate - how do I fix this so I can use Final Cut Pro?

    When starting Final Cut Pro 7.0.3 I am all of a sudden getting a message that says "One or more of the scratch disks don't have read/ write access" and now the app won't operate - how do I fix this so I can use Final Cut Pro?

    Glad you found the answer.  But something seems wrong.  FCP should be able to assign the scratch disk to your startup drive.  It's not advisable, but it should be possible.  You might want to try and figure out what's going on before what ever's going on cause other problems.

  • Write out file from java UDF?

    I have a synchronous RFC->XI->HTTP (no BPM) process and need to write out a log of the call details each time it runs.  At first, I tried having multiple receivers (one for HTTP and one for log file) in IB:Config, but received an error that I "cannot have multiple receivers when synchronous call".
    Should I be able to write out a file using java code in a UDF?  Should I do something with a BPM (and if so, any hints)?
    Thanks in advance!

    It deppends on which kind of log you want and how much time you're willing to spend on this.
    If you want to learn BPM and has available time to learn and implement, go for it. It will provide you more flexibility (since you can use any adapter protocol) and is way better for maintenance purposes.
    Your BPM will basically have 4 steps:
    1. A Receiver step in "Open S/A Bridge" mode;
    2. A Sender step in Asynchronous mode (to send the log message to your target system);
    3. A Sender step in Synchronous mode (to send the request to HTTP and receive the response);
    4. A Sender step in "Close S/A Bridge" mode.
    The mapping can be made in three ways:
    1. mapping between RFC and BPM (so your BPM will have abstract interfaces based on HTTP interface); or
    2. mapping between BPM and HTTP (so your BPM will have abstract interfaces based on RFC interface); or
    3. create 2 transformation steps in the BPM, one to map from RFC.request to HTTP.request and the other to map from HTTP.response to RFC.response (I'd not recomend this).
    Regards,
    Henrique.

  • Write out file through servlet

    Hello all,
    I wish to write out a file when a servlet is requested; however the file may be quite large and take a couple of seconds (approx 10) to write out. This results in a ten second delay for the user. I wish to offset this delay so the servlet continues executing returning the response and the file is written out in some form of background process.
    Could someone point me in the right direction?
    Thanks
    John

    Write up a Thread class to do the file writing for you. Your servlet will only start the thread with the required arguments and will generate the response without waiting for the thread to complete.

  • System.out and System.err  How to get to show up in log

    Does anyone know if there is anyway to get System.out and System.err
    messages to appear in the log?
    Trying to build and debug a JSP project is a complete nightmare when the
    remote developers cannot see System.out or System.err messages from helper
    classes.
    Platform= Windows NT 4.0
    Weblogic running as a Service
    Thanks in advance!

    Write a wrapper class to redirect the std out to what ever stream you want.
    HTH
    Saman

  • Why am I getting this error message: Unable to write the email to the mailbox. Make sure the file system allows you write privileges, and you have enough disk s

    I am getting this error message, just starting today: Unable to write the email to the mailbox. Make sure the file system allows you write privileges, and you have enough disk space to copy the mailbox. I have tried several solutions (cleaning out my inbox, compacting folders, rebooting, checking through the webmail side), all to no avail, Can anyone help?

    which os do you have?

Maybe you are looking for