How to decide ByteBuffer size created for SocketChannel.read(ByteBuffer)

Hi,
Is there any way by which we can know the size of data ready to be read at the SocketChannel?
When the "SelectionKey" is discovered to be "isReadable()" I would like to create the ByteBuffer of the required size and use it for the SocketChannel.read(ByteBuffer) method.
Right now I have to statically fix the ByteBuffer size to some safe maximum limit for this "read" method, which somehow is not looking efficient technique to me.
Thanks in advance
Amit

Java doesn't tell you how much data is pending, but allocating the ByteBuffer 'statically' in advance is a better technique anyway. ByteBuffers are potentially expensive to create so you should allocate them just once per channel. The size is generally 8k or above depending on how many clients you expect to service at the same time and the amount of memory you can spare per client and in total.

Similar Messages

  • How does the icon get created for a saved file

    In my program I allow saving files using JFileChooser and ActionListener.
    In the constructor of the main class which extends JFrame I also set an icon by saying:
    this.setIconImage(new ImageIcon("image.jpg").getImage());
    This does not only set an icon on the title bar and the minimized window, it also creates an icon on my saved files. However, the image quality for the icon on my saved files is bad, even though the image quality for the other icons is ok. The size of the icon image I am providing is close to the size of the icon image on my saved files.
    How did the icon get created for my saved files? Is it possible to improve the image quality?
    Thanks for looking at this!

    I just realized that
    this.setIconImage(new ImageIcon("image.jpg").getImage())
    did not create the icon for my saved files.
    So what did create it? I did not program it!
    However, I happen to have an icon file Ananya.ico where I have my java project. I use if for my installation file. Did Java use this icon?
    Please help! Thanks!

  • How Undo functionality can be Created for curves or Line in Swing?

    Please Help! How Undo functionality can be Created for curves or Line in Swing GUI. In the Java Tutorial, Undo with Text is given. But on implementing the SIMILAR logic of Undo with Text, some Errors come with Undo is to be Created on Swing GUI on the Graphics.

    What about storing the image before to execute the drawing method ? Undoing would be as easy as repainting the stored image ?

  • [svn:fx-4.0.0] 13527: changed how the mpl package is created for easier maintainability.

    Revision: 13527
    Revision: 13527
    Author:   [email protected]
    Date:     2010-01-15 10:59:08 -0800 (Fri, 15 Jan 2010)
    Log Message:
    changed how the mpl package is created for easier maintainability.  Previously I had been duplicating what the main pkg target was doing and just omitting the files that were not intended to be in the mpl pkg.  After the main pkg is bundled up the files not needed will be removed from the stage directory and then bundled up as the mpl package. fixes SDK-25039
    Straighten out the confusing packaging targets. 
    -sdk-packages is now packages -> calling this will package the flex_sdk_4 and mpl zips
    QE notes: the mpl + add-on package should give us the flex_sdk_4 pkg
    Doc notes:
    Bugs: SDK-25039
    Reviewer:
    Tests run: packaging targets
    Is noteworthy for integration: no
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-25039
        http://bugs.adobe.com/jira/browse/SDK-25039
    Modified Paths:
        flex/sdk/branches/4.0.0/build.xml

    Hi Harshall,
    You have to enter the value as 1 in Installed base field and then press enter.
    You will be taken inside and then you will be able to see the Goto - Partner screen.
    Hope this will help.
    Please reward points suitably.
    Regards,
    Naresh.

  • How many SECONDARY INDEXES are created for CLUSTER TABLES?

    how many SECONDARY INDEXES are created for CLUSTER TABLES?
    please explain.

    There seems to be some kind of misunderstanding here. You cannot create a secondary index on a cluster table. A cluster table does not exist as a separate physical table in the database; it is part of a "physical cluster". In the case of BSEG for instance, the physical cluster is RFBLG. The only fields of the cluster table that also exist as fields of the physical cluster are the leading fields of the primary key. Taking again BSEG as the example, the primary key includes the fields MANDT, BUKRS, BELNR, GJAHR, BUZEI. If you look at the structure of the RFBLG table, you will see that it has primary key fields MANDT, BUKRS, BELNR, GJAHR, PAGENO. The first four fields are those that all cluster tables inside BSEG have in common. The fifth field, PAGENO, is a "technical" field giving the sequence number of the current record in the series of cluster records sharing the same primary key.
    All the "functional" fields of the cluster table (for BSEG this is field BUZEI and everything beyond that) exist only inside a raw binary object. The database does not know about these fields, it only sees the raw object (the field VARDATA of the physical cluster). Since the field does not exist in the database, it is impossible to create a secondary index on it. If you try to create a secondary index on a cluster table in transaction SE11, you will therefore rightly get the error "Index maintenance only possible for transparent tables".
    Theoretically you could get around this by converting the cluster table to a transparent table. You can do this in the SAP dictionary. However, in practice this is almost never a good solution. The table becomes much larger (clusters are compressed) and you lose the advantage that related records are stored close to each other (the main reason for having cluster tables in the first place). Apart from the performance and disk space hit, converting a big cluster table like BSEG to transparent would take extremely long.
    In cases where "indexing" of fields of a cluster table is worthwhile, SAP has constructed "indexing tables" around the cluster. For example, around BSEG there are transparent tables like BSIS, BSAS, etc. Other clusters normally do not have this, but that simply means there is no reason for having it. I have worked with the SAP dictionary for over 12 years and I have never met a single case where it was necessary to convert a cluster to transparent.
    If you try to select on specific values of a non-transparent field in a cluster without also specifying selections for the primary key, then the database will have to do a serial read of the whole physical cluster (and the ABAP DB interface will have to decompress every single record to extract the fields). The performance of that is monstrous -- maybe that was the reason of your question. However, the solution then is (in the case of BSEG) to query via one of the index tables (where you are free to create secondary indexes since those tables are transparent).

  • How to decide component size to contain all data?

    Hi, all
    My application has some jtable and jtextarea which always contained in jscrollpane, not because what I need but because I don't have a idea to determine size for my component.
    Let's say my jtable has 30 rows, I know how to control width for columns. But how can I determine the height for jtable precisely? Should I allocate 15 pixel for a row, or maybe 20? How can I use a height for all platforms including windows,linux?
    It bothers me for a while, same stuff happened while I dealing with jtextarea. Do we have a guide line for this?
    Thanks,
    Vincent Chen

    That's why you put it in a scrollpane.
    Are you talking about setting the height or are you talking about knowing the height? Cuz setting it is typically non-sensical, since the # of rows tends to vary in a typical table. OF course, if you know it's X rows, you can get or set the row height in the table and just multiply by row count.

  • How to indentified work orders created for an trasfered asset in EAM

    Dear All,
    We have a businees requriment, where we need to list of workorders created for an asset which has been transfered from one EAM org to another EAM org.
    Business case :
    1.We have an asset BX3003 in WSB (eAM org), i have performed move asset transaction from maintenance super user to transfer this asset to other eAM org (GSW) and created a workorder in this org.
    2.Now we get this work order in to a custom report called work order created for transfered assets
    Can any one help us on this issue.
    Thanks a lot
    Praveen

    Hi,
    Yes, you can generate active calls into the future. First ensure that you have set a scheduling period in each relevant maintenance plan. This determines how far into the future you want calls to be generated. Also make sure the completion requiremment flag is not set.
    The calls can be generated via IP30 (or schedule with RISTRA20). Make sure the interval for call object is set to a sufficient length of time. This has the same function as the scheduling period in the plan. However the lower of these two values will be effective. To ensure the calls are not set on hold - set the immediate start for all flag. This setting will ensure the calls are scheduled and orders generated.
    -Paul
    Please use [Enterprise Asset Management (EAM)|Enterprise Asset Management (SAP EAM); forum for PM/CS specific topics   (I am moving the thread)

  • How to download a real setup for Adobe Reader 9?

    I have a friend who lives in the Sticks (and I do mean the back woods sticks) where she only has a 24.4 KBPS Modem connection to the internet.  I voluntered to download some updated software and I cannot figure out how to download the Windows 2000 version for her so I can put it on a CD for her to install when she gets home.
    I don't mean to be rude, but 26 Megs for a reader is a bit much and to insist that she use some Adobe Download Manager on a Land Line connection is outrageous.
    Please tell me you have a real download link.  I was able to get her everything else on her Christmas List but this.
    -Monica.

    You can snag it from their FTP site at ftp://ftp.adobe.com/pub/adobe/reader/win/9.x/9.3.3/enu/AdbeRdr933_en_U S.exe .
    It's more than 26MB though....

  • How to install several specified languages for Adobe Reader X

    Hi guys, just question that how to silencely install several specified languages for Adobe Reader X?
    I know some silence switch as below:
    setup.exe /sAll /rs
    =>  Silencely install all supported languages
    setup.exe /sAll /rs /sl "xxxx" (xxxx is LANG ID)
    =>  Silencely install one specified language only (defined by LANG ID)
    Question:
    If I would like to silencely install several specified languages, is there any other switch to do that?
    Thank you all in advance.

    Hi,
    I'm using Adobe Reader X MUI version and I tried your way but doesn't work unfortunately.
    I attached the setup.ini content below =>
    ============
    [Startup]
    RequireOS=Windows 2000
    RequireMSI=3.0
    RequireIE=6.0.2600.0
    [Product]
    msi=AcroRead.msi
    Languages=1033;1036
    1033=English (United States)
    1036=French (France)
    [Windows 2000]
    PlatformID=2
    MajorVersion=5
    ServicePackMajor=4
    [MSI Updater]
    Path=http://ardownload.adobe.com/pub/adobe/reader/win/8.x/8.0/misc/WindowsInstaller-KB893803-v2 -x86.exe
    =============
    And I used the switch of "Setup.exe /sAll /rs /ini "setup.ini""
    My OS is Windows 7 Ultimate.
    Thank you.

  • HT4623 how to download bibles from youversion for offline reading

    how to download bibles from youversion for offline reading

    If you install the app properly then all available versions will have been installed for reading offline. If you want audio on any particular version that provides that option then  you have to be online.

  • How do I set a password for adobe reader?

    how do I set a password for adobe reader

    You can set a password for your device (iPad or iPhone) in Settings. You cannot set a password on the Adobe Reader app itself.
    If you want to password protect a PDF document you cannot do it in Reader. It must be done in Acrobat on Macintosh or Windows.

  • How to decide buffer sizes for specific size of RAM

    Hi sdners.
    Generally, how can we decide the buffer sizes which are shown in the ST02 screen. suppose we have 100GB ram /5GB ram,  then how can we decide the related buffer sizes...and generally which buffer takes more place in the RAM
    Thanks in advance.

    Hi balaji
    You can tune your SAP buffer by the statistics of Hit Ratio and swap occuring.  There should not be no swap on your system. you can adjust your buffer value by the optimizing the both value.
    Regards
    Anwer Waseem
    SAP BASIS

  • How to decide the size of MTU when writing an interface ?

    I have very little knowledge about network interface. But I want to write a network interface. But I am not getting how the MTU for an interface is decided depending upon the network physical capabilities. Like :
    localhost has 1500 bytes
    But this size is not enough for high-speed networks which exist now a days. I am not getting how this size of MTU is actually affecting the network. And how we can find the optimal MTU for any network.

    This depends on what exactly do you mean by 'network interface'? Firmware for an NIC? a device driver for an NIC? Or you you mean an application API? And if so, for UDP or TCP?
    If UDP, all you need to know is that the practical limit on a datagram that has to go through routers is 534 bytes.
    If TCP, you don't have to worry about MTU in the slightest.

  • How increase external disk size used for an existing file system, Solaris10

    Configuration:
    Server: Sun T5220
    S/O: Solaris 10 5/08 s10s_u5wos_10 SPARC
    Storage: EMC AX4-5
    EMC PowerPath: PowerPath Version 5.2
    I have the following scenario:
    In AX4-5 storage array, I created two LUNs into RAID Group 10, with Raid Type1/0:
    LUN 101: 20Gb
    LUN 102: 10Gb
    Both LUNs were added to Storage Group (SG1) that includes two Servers (Server1 and Server2); both servers have Operating System Solaris 10 5/8 and Power Path.
    The servers detect both LUNs across two paths. With Power Path were created a virtual path (emcpower0a, emcpower1a) to access to each LUNs respectively.
    We have mounted two file system /home/tes1 over emcpower0a -> LUN101 and /home/tes2 over emcpower1a -> LUN102.
    Filesystem size used avail capacity Mounted on
    /dev/dsk/emcpower0a 20G 919M 19G 5% /home/test1
    /dev/dsk/emcpower1a 10G 9G 1G 90% /home/test2
    I want to increase the space in file system /home/test2, without lost the information that I have stored and using the same LUN, LUN 102. To do this I start with the following steps:
    1-     Create new LUN, LUN 103 with 15Gb into RAID Group 10. Result: OK, I have available space in RAID Group 10.
    2-     Add LUN 103 to LUN 102, using concatenation option. Result: OK. This action creates a new metaLUN with the same characteristics of LUN 102, but with new space of 25Gb.
    After to do these actions, I want to know how Solaris recognize this new space. What I need to do, to increase the size of file system /home/test2 to 25 Gb. Is that possible?
    I reviewed the description of each disk using format command, and the disks not have any change.
    Could anyone help me? If you need more detail, please do not hesitate to contact me.
    Thanks in advance.

    Robert, thank a lot for your know how. You helped me to clarify some doubts. To complete your answer, I will add two more details, based on my experience.
    After to execute, type -> auto configure and label, the disk was created with different partitions like root, swap, usr, like this:
    Volume name = < >
    ascii name = <DGC-RAID10-0223 cyl 49150 alt 2 hd 32 sec 12>
    pcyl = 49152
    ncyl = 49150
    acyl = 2
    nhead = 32
    nsect = 12
    Part Tag Flag Cylinders Size Blocks
    0 root wm 0 - 682 128.06MB (683/0/0) 262272
    1 swap wu 683 - 1365 128.06MB (683/0/0) 262272
    2 backup wu 0 - 49149 9.00GB (49150/0/0) 18873600
    3 unassigned wm 0 0 (0/0/0) 0
    4 unassigned wm 0 0 (0/0/0) 0
    5 unassigned wm 0 0 (0/0/0) 0
    6 usr wm 1366 - 49149 8.75GB (47784/0/0) 18349056
    7 unassigned wm 0 0 (0/0/0) 0
    This was not convenient because all information stored appear in the first slice and growfs not work if appear root or swap slice into the disk, for that reason was necesary to recreate manually every slice with partition command. The final result was this:
    Part Tag Flag Cylinders Size Blocks
    0 unassigned wm 0 - 49149 9.00GB (49150/0/0) 18873600
    1 unassigned wu 0 0 (0/0/0) 0
    2 backup wu 0 - 49149 9.00GB (49150/0/0) 18873600
    3 unassigned wm 0 0 (0/0/0) 0
    4 unassigned wm 0 0 (0/0/0) 0
    5 unassigned wm 0 0 (0/0/0) 0
    6 unassigned wm 0 0 (0/0/0) 0
    7 unassigned wm 0 0 (0/0/0) 0
    Now, execute again the label command to save the new information.
    Mount file system and execute:
    growfs –M file_system mount_point to expand the file system to 9Gb.

  • When, where, and how is a GUI event created for a Swing component?

    Somebody please help me with this issue !
    Heavy weight (AWT) components such as JFrame, JDialog, JApplet, and JWindow have
    native peers. As I understand, the senario of event creation for such heavy components
    is something like follows:
    1. A mouse click happens in a heavy component.
    2. The native platform (i.e. the OS) captures the mouse click event and
    store it as a native event somewhere in the system.
    3. java.awt.EventDispatchThread gets this message and translates the native message
    into an AWTEvent. When creating the AWTEvent, AWT actually looks up a hashtable
    for the reference to the heavy component from the reference to the native window.
    The hashtable stores all the pairs of heavy components and their native peers ever
    created during the session. Now the AWTEvent includes a reference to the "source"
    component that generates the event.
    4. java.awt.EventDispatchThread dispatches the AWTEvent to the heavy component
    for furture processing.
    As for light weight (Swing) components such as JButtion, no native peers are attached.
    So, there is no mapping from native peers to light weight components.
    After a mouse click happens over a JButton, how, when, and where is the corresponding
    event created and finnally routed to JButton. Could somebody give a sketch of the
    senario? Thanks a lot.

    Basically for Swing components, it would have to figure out based on the size and location of the components which one the click happens in. One could simply know that this panel is so big and it has such and such components in it which are however big and located at whatever point. It's a matter of digging down through components to find the lowest (or would it be highest) one.

Maybe you are looking for

  • How to restrict users' event on a column report

    Hello All, I wrote a classical report with hotspot on one field. I used a parameter ID to skip the transaction screen to avoid an extra click for users. My question is restricting an event to the 'only' column where the hotspot is defined. I found ou

  • Too many distributed transactions

    I am programming an application with JDeveloper 10g and ADF Framework. It is a application that only queries data (no modifications). I created ViewObjects based on sql queries and an application module. The problem is that is I execute that applicat

  • [SURVEY] Oracle Certification eCertificates

    We are interested in how you, the candidates, feel about the possibility of providing electronic success kits. Please take a few minutes to complete this short survey to help us evaluate this initiative. Please note that your opinions will only be re

  • Printers in Oracle Applications over NT

    I'm trying to set up network printers in Oracle Applications 11.0.3 to work over an NT network. I've done Install\Printer\Register, but it seems OA doesn't see NT printers correctly or viceversa. Can anybody point me in the right direction? Thanks.

  • Why do I get these smear like pixelation glitches in my video after exporting?

    This is what the glitch looks like. I am using Adobe Premiere CS3 I made a sequence using mp4 files recorded at 15 mbps, so they are high quality clips. I exported my finished video using H.264 (mp4) at 1080p and 12 mbps. I even tried using 2 pass as