The contract for java.io.OutputStream.flush()

The Javadoc for method java.io.OutputStream.flush() is
public void flush()
           throws IOException
    Flushes this output stream and forces any buffered output bytes to be written out. The
general contract of flush is that calling it is an indication that, if any bytes previously
written have been buffered by the implementation of the output stream, such bytes
should immediately be written to their intended destination.Thread http://forums.sun.com/thread.jspa?threadID=5318876&tstart=0 highlighted a problem with this contract in that there are some OutputStream such as CipherOutputStream (when using PKCS5Padding) where it does not make sense to implement to the flush() contract. In meeting this contract one would have to close the stream so that nothing else could be written after a flush. The reason for the problem is that only complete blocks of data can be written. Until one has a complete block, the bytes of an incomplete block have to be stored in the CipherOutputStream. Only when one closes a CipherOutputStream can the bytes of the incomplete block be padded to create a complete block, encrypted and then written.
I have a similar problem with my Base64OutputStream where I can only write a multiple of 3 input bytes until I close() when I can provide appropriate padding.
So, should one do as ghstark proposed in http://forums.sun.com/thread.jspa?threadID=5318876&tstart=0 and close() the stream when one flushes it or should one do as I currently do and only write out as much as possible without closing the stream. It would seem that one either has to break the flush() contract or break the encryption (or in my case Base64) contract.
I would appreciate comments.

DrClap wrote:
Well, if it were me I would probably redefine the flush() method to only write the bytes that I was ready to write. So in your Base64 case I might be holding back one or two bytes.That is exactly what my Base64OutputStream and Sun's CipherOutputStream do.
If challenged on that I would just say that my flush() method conformed to the contract because those bytes weren't "buffered" yet.I like the concept but any wording would have to be carefully written. I suppose that I could argue that I have not buffered any bytes that could be written so I have not buffered any bytes.

Similar Messages

  • How to download the Javadoc for Java 7

    I can't find the download for the Javadoc for Java 7. This is needed for the NetBeans auto help function. Where is it please?

    This might help - http://download.oracle.com/javase/7/docs/technotes/guides/javadoc/index.html
    HTH
    Srini

  • Capturing electronic signature in the Webdynpro for java applicaiton.

    Hi! All,
    Can you please tell me the way to capture the electronic signature in my Webdynpo for Java application.?
    Thanks and Regards,
    M.D.Sahu

    Hi,
    I did it with IFrame control that generates a script (javascript) with Smart Card.
    The user has a smart card with electronic id, when the user wants to sign the form the script generate a smrt card logon.
    The user has to identify with finger print and the electioc signiture is added to the form (Adobe).
    the main issue  in this project was where to activate  script (server side or client side).
    enjoy,,,,
    AmitY

  • Extend the contract for other plants

    Hello All
    I had a situation i have to distribute a contract for other plants too .
    for eg. i have created one CONTRACT 4500002 for plant 1200 material 12345 - this is existing
    now i want to make it available for all remaining plant 1300,1400 and 1500 plants too  12345 . price for all the palnts same for that material 12345.
    what is the good practice we can do for customer.
    should i add same material for all plants with another 3 line item for the existing contracts.
    br
    Muthu

    Hi,
    please enter 3 more line items for plants 1300,1400 and 1500 for the same material 12345 in the existing contract 4500002 and same price for all.
    when you create contract release order you can create as per your requirement.
    Regards
    Hari

  • Is annotation processing the same for Java 5 and Java 6?

    I've been trying to use a package of annotations and processors that was evidently originally designed to be used with "apt" and Java 5. When I try to use this stuff with Java 6 I was assuming that, since the Java 6 javac handles annotations, I could just use javac instead of apt - but it doesn't work; the annotation processors don't appear to be getting executed. It looks like I have to use apt for the Java 6 build after all.
    The question is, did the annotation mechanism change significantly between 5 and 6 that would account for this? Is there a way to adapt an annotation package (i.e. annotation classes and processors) that works with 5 so that it will work with 6 using javac instead of apt (or alternatively, is there a way to tell javac to process the older annotations in the same way that apt would)?

    PeteFord wrote:
    I've been trying to use a package of annotations and processors that was evidently originally designed to be used with "apt" and Java 5. When I try to use this stuff with Java 6 I was assuming that, since the Java 6 javac handles annotations, I could just use javac instead of apt - but it doesn't work; the annotation processors don't appear to be getting executed. It looks like I have to use apt for the Java 6 build after all.
    The question is, did the annotation mechanism change significantly between 5 and 6 that would account for this? Is there a way to adapt an annotation package (i.e. annotation classes and processors) that works with 5 so that it will work with 6 using javac instead of apt (or alternatively, is there a way to tell javac to process the older annotations in the same way that apt would)?If you have apt annotation processors, you can use the apt command in JDK 6.
    However, the javac in JDK 6 support standardized JSR 269 annotation processing; see the javax.annotation.processing package. JSR 269 annotation processing is significantly redesigned and improved based on experiences with apt.
    It would be "a small matter of programming" to port an apt annotation processor to JSR 269.
    Using apt in JDK 6, you can also run both apt and javac processors from a single command line invocation.

  • SAPehp tool does not know the host for Java stack

    I  am running SAPehp tool to apply enhp2 to a dual stack with
    ABAP and JAVA on seperated Windows boxes.
    I started SAPehp at the ABAP box.
    Because there is no way to tell where is the Java host, how do I apply
    the enhp2 to the Java side? How to make ABAP and Java in sync?
    Please help.
    Thanks!

    Hi Christy,
    I consider that both of your ABAP and Java system has separate database. If this is the case then you have to upgrade both system separately and run EHPI installer on both system. You can upgrade the system in same way as you are doing for your ABAP system only difference is the support packages and rest of the main things are same.
    I will recommend you to study upgrade guides for ABAP and Java system.
    If your ABAP and Java system has different SID but share same database (i.e. MCOD system) then run EHPI installer for upgrade once a time. It means that when you will upgrade the ABAP stack then don't run EHPI tool to upgrade Java stack at same time. Once ABAP system upgrade finished then upgrade Java system. And vice-versa.
    Thanks
    Sunny

  • Did the markup for java applets change with version 4.0.5

    Starting with Safari version 4.0.5 java applets are not rendering correctly. The Java coffee cup loading image pushes the actual content down. Was the applet tag markup changed with this release?
    Take a look at the following example:
    http://tinyurl.com/p27vpq
    or
    http://preview.tinyurl.com/p27vpq
    FYI, 4.0.4 displays correctly.

    Ok...
    First, try a different user account with Safari and see if the same thing happens. If it does then it's a system wide issue, not just your user account.
    From the Safari Menu Bar, click Safari / Empty Cache. When you are done with that...
    From the Safari Menu Bar, click Safari / Reset Safari. Select the top 5 buttons and click Reset.
    Go here for trouble shooting 3rd party plugins or input managers which might be causing the problem. Safari: Add-ons may cause Safari to unexpectedly quit or have performance issues
    Web pages now include a small icon or 'favicon' which is visible in the address bar and next to bookmarks. These icons take up disk space and slow Safari down. It is possible to erase the icons from your computer and start fresh. *To delete Safari's icon cache using the Finder, open your user folder, navigate to ~/Library/Safari/ and move this file "webpageIcons.db to the Trash.*
    Relaunch Safari.
    If you still have problems, go to the Safari Menu Bar, click Safari/Preferences. Make note of all the preferences under each tab. Quit Safari. Now go to ~/Library/Preferences and move this file com.apple.safari.plist to the Desktop. Relaunch Safari. If it's a successful launch, then that .plist file needs to be moved to the Trash.

  • Unable to import the package for java concurrent program

    Hi all
    i m trying to work on java concurrent program ,but when i tried to import these classes
    import oracle.apps.fnd.cp.request.CpContext;
    import oracle.apps.fnd.cp.request.JavaConcurrentProgram;
    the compiler is throwing
    cannot access class oracle.apps.fnd.cp.request.CpContext; file oracle\apps\fnd\cp\request\CpContext.class not found
    it is not giivng the cp package
    please can somebody have idea ,what could be the reason .
    thanx in advance
    regards
    pratap

    Pratap,
    Please download the cpcontext files whose package structure is oracle.apps.fnd.cp.request.CpContext
    from the google or other search sites or download it from application unix server $JAVA_TOP/oracle/apps/fnd/cp/request/CPContext .
    If it is a class file then convert it to java file by using java decompiler.
    then plalce the file respective folder by creating folder of this name. e.g. if
    the package structure is oracle.apps.fnd.cp.webui the create folders in myproject folder in jdeveloper
    oracle, then under oracle folder cretae aapps folder and so on...
    Thanks,
    Kumar

  • Checling the exception for Java code

    Hi,
      I am using SAP EP 6.0 WAS 6.20
        I have a java code which tries to get initial context
      try
          //try{
                     Properties p = new Properties();
                   p.put(Context.INITIAL_CONTEXT_FACTORY, "com.inqmy.services.jndi.InitialContextFactoryImpl");
                   //p.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.InitialContextFactoryImpl");
                     p.put(Context.PROVIDER_URL, "137.72.229.238:50004");
                     p.put(Context.SECURITY_PRINCIPAL, "Administrator");
                     p.put(Context.SECURITY_CREDENTIALS, "password");
                     Context ctx = (Context) new InitialContext(p);
                              Object objRef = ctx.lookup("SAPEPUMEBean");
                   UMEEJBHome ejbHome =  (UMEEJBHome)objRef ;
                   objUMEBean = ejbHome.create();
    }catch(NamingException namingEx)
    This code throws a naming exception.
    I wanted to know in which file this exception stacktrace will be present .
    Regards
    Manoj

    Hi,
    On the filesystem look in folder:
    C:\usr\sap\XXX\XXX\j2ee\cluster\server\log
    In Visual Administrator:
    Open server node, services, Log viewer.
    In the right panel open Server node, select path (C:\usr\sap\XXX\XXX\j2ee\cluster\server\log).
    Good luck,
    Roelof

  • HT5364 How can I change the security for java? I cannot upload a picture.

    Hello there,
    I cannot upload a picture to a site. I have attached the error message with the hope someone knows what I need to do?
    thanks

    Hi,
    Picture Uploading here is handled by javascript within the page.
    It is enabled in Safari like this
    The Internet Plug-ins may have the Java App plug-in if you have Installed Java.
    It does look more likely that it is a Plug-in that is the trouble. I mention javascript due to the similarities in name and the fact either could be used.
    9:31 pm      Monday; March 10, 2014
    ​  iMac 2.5Ghz i5 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

  • Apply the license for Java stack

    Hi
    Any one can you guid me how to apply the sap license in java stack by visual administrtor but i am not able to open the visual administrator
    the error is
    unable to lookup connection default
    http://xxxx:8101/msgserver/text/logon returned empty list of connection parameters
    please guid me sort out this issue...
    Thanks,
    Jayson

    Hi,
    First login in to the visual admin using the exe file
    usr/sap/sid/instance/j2ee/admin/go.bat
    then select the default connection if there is no such connection then create a new connection enter the port as 5xx04 and localhost.
    Then select the direct connection to dispatcher and try to login in using this new connection user should be j2ee_admin.
    Regards,
    Vamshi.

  • Sales order create/change line item with reference to contract - Open quantity not getting deducted for copied line item from the contract

    Hi friends,
    Please provide some valuable inputs for the following scenario:
    When a sales order line item is created(VA01) or changed(VA02) with reference to a Contract the open quantity is deducted in the contract which is a standard functionality. If the referenced line item is copied (custom enhancement to copy line item), then for the copied line item the open quantity is not getting deducted instead ATP quantity i.e. Available-to-promise is deducted.
    Any inputs on how we can fix this functionality i.e. deduct the open quantity from the contract for the copied line item?
    P.S. : Custom enhancement to copy line item is working fine, but open quantity is not getting deducted if the copied line item was referenced to a contract.
    Thanks,
    Sandeep
    Message was edited by: sandeep

    Sandeep,
    Yes, that was my original interpretation.  I was having a hard time believing that someone would ask such a question. 
    I guess, then, that you already know that you will have to add this logic to your enhancement. You should create your specifications and hand them off to a developer; ideally the one who created this enhanced solution in the first place.
    I do not provide advice in these forums about details of enhanced solutions.  Perhaps one of the other members will be more willing to do your work for you.
    Best Regards,
    DB49

  • What's the best XML for JAVA?

    Hi There,
    My big question is what should I use for develop a normal XML document, that can:
    - contain BASE64 strings
    - support UTF-8 add attributes, etc.
    I then want to pick this document and:
    - do it's parsing (walk trough)
    - apply a xsl to this document.
    I've made this in C using libxml2 for WIN32/HP-UX, and also in VB using msxml4, now I must make the same document in Java, I see a lot of alternatives but really don't know what to choose...
    In these languages I pick a structure that we support (similar to a tree) and serialize it to XML, send it as a string and then rebuild the initial structure with flaws. Each client can have a xsl file to show the information in the way he wants to.
    So, I ask your opinion what's the best for JAVA (a fast learning curve is preferable, but speed of processing is very, very important)?
    Thanks in advance for all the replies,
    Lu�s Pinho

    Have you looked at Apache's XML Beans?
    http://xml.apache.org/xmlbeans/

  • Hi i wrote a java program for scanning a system for java.exe 's

    hi ,
    i wrote a program which scans the system for java.exe 's and then it captures them in a linked list and then i
    iterate through it for "\\Java\\jdk1.5.0_08\\bin\\java.exe and my aim is to return true in case the linked list contains the string "\\Java\\jdk1.5.0_08\\bin\\java.exe" and stop scanning the system.
    If the linked list does not contain "Java\\jdk1.5.0_08\\bin\\java.exe" it should return false.
    But my problem is the program is continuing to scan the system even if the linked list has "\\Java\\jdk1.5.0_08\\bin\\java.exe"
    Any sort of help is appreciated.
    The code is as follows:
    package com.installanywhere.exper;
    import com.zerog.ia.api.pub.CustomCodeRule;
    import com.installanywhere.exper.SearchTool;
    * @author
    public class eFileTool extends CustomCodeRule {
         /* (non-Javadoc)
         * @see com.zerog.ia.api.pub.CustomCodeRule#evaluateRule()
         @Override
         public boolean evaluateRule() {
              // TODO Auto-generated method stub
              SearchTool searchtool=new SearchTool();
              boolean valueTocheckfor=false;
              valueTocheckfor=searchtool.find();
              String someothervalue=Boolean.toString(valueTocheckfor);
              if(someothervalue.equalsIgnoreCase("true")){
                   return true;
                   //System.exit()
              else if(someothervalue.equalsIgnoreCase("false")){
                   try {
                        Thread.sleep(5000);
                   } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
              System.out.println(valueTocheckfor+"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
              return valueTocheckfor;
    The code of search tool is
    package com.installanywhere.exper;
    import java.io.*;
    import java.util.*;
    public class SearchTool
         * @param args
    static     boolean valuesToReturn=false;
    static     boolean anothervalueToRefer=false;
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              SearchTool           t = new SearchTool();
              System.out.println("xxxxxxxxxxxxxxxxxxxx");
              boolean someArgument=t.find();
              System.out.println(someArgument+"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"+"");
                   public boolean find()
                        System.out.println("2222222222222222222");
                   boolean someThing=searchcomp("java.exe");
                   System.out.println(someThing+"inside the othere one");
                   return someThing;
              public boolean searchcomp(String file)
                   System.out.println("3333333333333333333333");
                   File[] drives=File.listRoots();
                   boolean valueIdentified=false;
                   for (int ctr=0;ctr<(drives.length-1);ctr++)
                        valueIdentified=search(drives[ctr],file);
                        System.out.println("4444444444444444444");
                   System.out.println(valueIdentified+"something i need to accomplish");
                   return valueIdentified;
                   public boolean search(File dir,String file)
                   File[] directories=dir.listFiles();
              System.out.println("55555555555555555555555");
                   if (directories == null)
                        System.out.println("666666666666666666666666");
                   return false;
                   for(int ctr=0;ctr<directories.length;ctr++)
                        if(directories[ctr].isDirectory())
                             System.out.println("77777777777777777777777777");
                             valuesToReturn=search(directories[ctr],file);
                             System.out.println(valuesToReturn+"india is great");
                        else
                             if(directories[ctr].getName().equals(file))
                                  String path = directories[ctr].getAbsolutePath().toString();
                                  System.out.println(path);
                                  List someList=new LinkedList();
                                  anothervalueToRefer=allPaths(path);     
                                  System.out.println(anothervalueToRefer+"god damn it");
                                       //System.out.println(anothervalueToRefer+"let me seeeeeeeeeeeeeeeeeee");                                        
                                  return anothervalueToRefer;
                   return valuesToReturn;
                   public boolean allPaths(String allPath)
                        List l=new LinkedList();
                        String somepath=allPath;
                        l.add(somepath);
                        //return l;
    /*if(l.contains("C:\\Program Files\\Java\\jdk1.5.0_08\\bin\\java.exe")){
                             System.out.println("yepeeeeeeeeeeeeee");
                             //System.exit(0);
    else{
         System.out.println(" the face");
                        ListIterator li = l.listIterator();
                        System.out.println("inside the method of all paths");
                        if(li.hasNext())
                             if(li.next().toString().contains("\\Java\\jdk1.5.0_08\\bin\\java.exe"))
                             System.err.println(somepath+"this is the path i wanted to resolve correctly");                         
                             return true;
                             else{
                                  System.out.println("trueeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
                                       return false;
                        else {
                                  return false;
         }

    A good place to ask advice about web development is at the MozillaZine "Web Development/Standards Evangelism" forum.
    *http://forums.mozillazine.org/viewforum.php?f=25
    The helpers at that forum are more knowledgeable about web development issues.<br>
    You need to register at the MozillaZine forum site in order to post at that forum.

  • Problems with JNDI lookup for java:comp/env/ejb

    Hi all,
    I'm using OC4J 9.0.3 and I have problems when looking up for the local
    EJB context.
    I have a SLSB which refers to another SLSB via a JNDI mapping like
    shown below. Both services are deployed within one EAR file.
    (snippets of ejb-jar.xml and orion-ejb-jar.xml)
    <ejb-jar>
    <enterprise-beans>
    <session>
    <ejb-name>ServiceABean</ejb-name>
    <home>com.coi.ServiceAHome</home>
    <remote>com.coi.ServiceA</remote>
    <ejb-class>com.coi.ServiceABean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    <ejb-ref>
    <ejb-ref-name>ejb/some/sub/packages/ServiceB</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <home>com.coi.ServiceBHome</home>
    <remote>com.coi.ServiceB</remote>
    </ejb-ref>
    </session>
    </enterprise-beans>
    </ejb-jar>
    <orion-ejb-jar>
    <enterprise-beans>
    <session-deployment location="global/some/sub/packages/ServiceA" name="ServiceABean">
    <ejb-ref-mapping name="ejb/some/sub/packages/ServiceB" location="global/some/sub/packages/ServiceB" />
    </session-deployment>
    </enterprise-beans>
    </orion-ejb-jar>
    The ApplicationInitialContextFactory will be used (prepared by the container),
    so the lookup for ServiceB within a method of ServiceA should work as follows:
    public class ServiceABean implements SessionBean
    public void someMethod()
    InitialContext con = new InitialContext(); // will be of class ApplicationContext
    Context localEjbContext = (Context)con.lookup( "java:comp/env/ejb" );
    ServiceBHome serviceBHome = (ServiceBHome) PortableRemoteObject.narrow(
    localEjbContext.lookup( "some/sub/packages/ServiceB" ),
    ServiceBHome.class );
    The problem is now, that the lookup for "java:comp/env/ejb" doesn't work
    and throws a NameNotFoundException.
    To figure out what's actually happening during lookup I debugged a little bit and
    tried a few things:
    1. A lookup for "java:comp" works fine. It returns an instance of class FlatMapContext
    which consists of a hash map which itself contains an entry for "env".
    2. So a lookup for "env" on that FlatMapContext also works and returns an instance of SubContext.
    3. A lookup for "ejb" using this SubContext causes a NameNotFoundException
    with message "java:comp/env/ejb not found".
    4. A lookup like con.lookup( "java:comp/env" ) throws also a NameNotFoundException
    with message "java:comp/env not found (not inside a J2EE module, for instance a Web-App,
    EJB, or Application-Client)".
    Does anyone know something about this?
    Regards
    --thomas

    Hi Debu,
    Great! 9.0.4 will be released in june/july this year, right? Sorry for my ironical reaction, but does that mean, that I don't have any chance to get my whole stuff running in 9.0.3? I cannot believe that. Isn't there a wordaround I could apply? A setting or whatever to substitute the daft FlatCtx by something else that is implemented according to the spec?
    Regards
    --thomas

Maybe you are looking for

  • Got the 6870 twin Frozr do I need a bios update?

    I returned my Gtx 560 and got the 6870 twin frozr oc. I like it much better. Do I need a bios update for this card? I'm assuming I have the stock version... Thanks

  • Using relational data from SQL data source in Planning and Essbase

    Hi, How do I take sample data from a SQL data source and bring it into a Hyperion Planning application? I understand that when creating Planning applications, a link between a relational data source and Essbase must be established, because the relati

  • Download of legacy version - Acrobat X Standard (supplied with DELL laptop)

    Hi, I have to re-install my DELL laptop purchased with a Acrobat X Standard license. After spending some 2 hours for searching I'm desperate ... I can't find a download for this version. Is there any database for such old versions ?!?

  • Creating a custom 404 message

    This is somewhat beyond an iWeb topic, but I thought I'd try. .. I would like to create a custom 404 message because Google picked up on some of the pages that I have since deleted. My webhost says to create my custom error html page and to also crea

  • Font cut off in iWeb slideshow

    I'm having all kids of font problems working on my website, looks like iWeb has some issues. Right now I would like to fix the font on my slideshows. I set the caption number to 5 on the Album page, then when you click on an image and go to its own p