How to find length(in Bytes) of an Inputstream

Hi ,
I have a dynamic InputStream which is coming from a HTTPRequest .
My requirement is to read the data in stream more than once . If i read the data using read(), it will read the entire data and for the subsequent reading it is not allowing .
So, is there any way to read a stream more than once .
Is it possible to get the length(in Bytes) of an InputStream

rajeshreddyk wrote:
My requirement is to read the data in stream more than once . If i read the data using read(), it will read the entire data and for the subsequent reading it is not allowing .
So, is there any way to read a stream more than once .Store the data somewhere on your end, then re-read as often as you fancy.
PushbackInputStream may offer the desired functionality, IF you know the message size in advance (which you should, if it's HTTP). I'm not quite certain it should be used for very large streams, though.
Alternatively (and probably better), write all your data once to a BAOS, and re-read from it (using a BAIS).
Is it possible to get the length(in Bytes) of an InputStreamNo, not as such.
However, a specific protocol may stipulate that the message size should be written to the stream (as data), and thus the recieving end would know how much data there is to read.
In HTTP, this is handled with the Content-Length header parameter.

Similar Messages

  • How to find Length of String

    Hi
    how to find length of a string.. i have a requirement that user cannot add more than 9 digits in a string.. i am new to WD Abap..
    Regards,
    Puneet

    Hi,
    You can use STRLEN command for your requirement.
    First read your input field using code wizard.
    Then using STRLEN command you can find the length of the Input field.
    For Example :
    Here input is your input field.
    data :    length type i.
    length = strlen(input).
    If length < 9.
    raise error msg.
    endif.
    Edited by: Viji on Mar 26, 2008 11:30 AM

  • How to find length of integer elements using message mapping

    Hi all,
             How can I find the number of digits in an element using message mapping
    XIer

    Satish,
               Cause I have to write the code for 100 elements, I have decided to have a AUDF with two inputs;
    1) for the element
    2) for the length of the data type (I am passing length using Constant message mapping func).
    Now when I change my UDF and try running it I get the following error:
    <b><i>Start of test
    Source code has syntax error:  /usr/sap/B06/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map0999e66045cf11dcc83b4ebcfc11da82/source/com/sap/xi/tf/_MM_Recordcount1_.java:160: operator >= cannot be applied to int,java.lang.String if(Element_Name.length()>=Element_Length) ^ /usr/sap/B06/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map0999e66045cf11dcc83b4ebcfc11da82/source/com/sap/xi/tf/_MM_Recordcount1_.java:166: operator <= cannot be applied to int,java.lang.String for(int i=Element_Name.length();i<=Element_Length;i++) ^ 2 errors</i></b>
    The code I have used is:
    public String Include_Space(String Element_Name,String Element_Length,Container container)
    {StringBuffer sb= new StringBuffer();
    if(Element_Name.length()>=Element_Length)
    return""Element_Name"";
    else
    for(int i=Element_Name.length();i<=Element_Length;i++)
    if(i==Element_Name.length())
    sb.append(Element_Name);
    else
    sb.append(" ");
    return ""sb.toString()"";
    Pls advice, where I am going wrong...
    XIer
    Message was edited by:
            XIer

  • How to find length of string after encryption using DBMS_CRYPTO package

    Hi,
    I am planning do data encryption using DBMS_CRYPTO package. I want to find how much will be string length after encryption.
    e.g When I try to encrypt string of length between 1-15 characters it gives me encrypted string of 32 characters. When I try with 16 charcters encrypted string is of 64 characters.
    Is ther any formula to calculate length of encrypted string?
    Thanks
    Pravin

    The length change is dependent upon the algorithm you are using which can be a combination of cipher block, padding, and chaining.
    The best solution is determine the method you are going to use and apply it to the l ongest possible strings you are going to proces, then add some safety margin. There iis no penalty for defining your column as VARCHAR2(4000).

  • How to find no of bytes per character in a word - Urgent need

    Hi,
    I have some data in the database with chinese characters. I want to know how many bytes per each character in a word and get the total bytes.
    Is there any built in Oracle function or anything where i can get no of bytes for each character or a word.
    I am not able to find the solution anywhere.
    Any help is appreciated.

    Hi,
    You can use LENGHTB function.
    SQL>SELECT LENGTHB(dummy) FROM DUAL;
    LENGTHB(DUMMY)
                 1
    1 row selected.
    SQL>Regards

  • How to find length of a string in JSF using EL expressions.

    I am doing it as below for finding string length
    <c:set var="test" value="#{myPageBean.myMethod.length()}" />
    While evaluating the above expression,it will call getMyMethod() which will return a String. On that it will call length().
    But it this throwing parsing error,
    Is it different in JSF?..Pls help.

    BabuKhan wrote:
    I have imported the taglib in th below 3 ways and tried
    1. <anyxmlelement xmlns:fn="http://java.sun.com/jsp/jstl/functions" />
    2. <anyxmlelement xmlns:fn="http://java.sun.com/jstl/functions" />
    3. <anyxmlelement xmlns:fn="http://java.sun.com/jsf/functions" />
    Literally? Do you understand the meaning of "anyxmlelement" ?

  • How to find length of a composition in 'time' not 'bars'?

    I'm sure this must be obvious, but when composing in Garageband 2.0 for iOS, how can I tell how long my composition is in actual time? All I can see is bar numbers, rather than the option to switch to viewing in minutes and seconds. If I need to compose a piece that is (say) 1 minute in length (eg to match a video being made in iMovie), how can I tell this while composing? I know it's easy in Garageband for Mac, and I often switch back and forth between bars and time, but on iOS I must be blind I don't want to have to guess....
    Thanks for your help!
    Carol

    Thank you, léonie. I was afraid it might be something like this. I'm working with some younger students in a school, and want to make it easy for them, without all the calculations  I thought someone else might have had the same problem, but I can't see any other questions along this line. Hence, I assumed I was missing something simple!
    We'll see what else eventuates!

  • How to find length of a character variable in sap script

    Hi,
    I have stored a line of text in one variable. If the text exceeds more than 50 characters, the remaining characters will be printed in next line.
    For this i have given code as :
    <I>&S_BOL_SUMMARY-TXT(50)&</>
    <I>&S_BOL_SUMMARY-TXT+50&</>
    The problem is i have to print the second line only when the text exceeds more than 50 characters. So how can i give the condition for that?
    Ezhil

    Hi,
    Try the following,
    data: len type i.
    len = strlen (S_BOL_SUMMARY-TXT ).
    if len > 50.
    &S_BOL_SUMMARY-TXT(50)&
    &S_BOL_SUMMARY-TXT+50&
    else.
    &S_BOL_SUMMARY-TXT(50)&
    endif.

  • How to get the length in bytes of a string

    My string has both latin (1 byte) and chinese (2 bytes).
    My program is in unicode system.
    How to measure the length in bytes of the string?
    the xlen function does not work.

    Hello,
    parameters : p_str type string.
    data : len type i.
    len = strlen( p_str ).
    write : / len.
    With Regards,
    BVS
    Hi BSV, your code return the number of characters not bytes.
    Remember chinese character in US are encoded with 2 bytes.
    And my string contain both latin and chinese characters.
    thanks

  • How to find the length of the resultset

    how to find the length of the resultset

    (Doing a select count as somebody suggested is nota
    good solution, as the count can change betweenyour
    count query and your real query.)And the number of rows can't change between getting
    the last one and doing the actual work?I don't think so. Once you've got the ResultSet, I don't think it will change under you, unless you explicitly set it to SCROLL_SENSITIVE.
    I could be mistaken though.

  • How to find the size of the pipe. I mean the total number of bytes/messages available in the named pipe?

    How to find the size of the pipe. I mean the total number of bytes/messages available in the named pipe?
    NAVEEN

    I'm afraid this forum for Microsoft Project Customization and Programming  is not the correct forum for your question. Please Choose correct forum in order
    to get help from experts. I think your question is more relevant to SQL server
    kirtesh

  • How to find hp build id and feature byte id

    how to find hp build id and feature byte id in HP Elitebook 8460p

    After debugging SM04, we found somthing below:
    Report           RSM04000_ALV
    call 'ThUsrInfo' id 'OPCODE' field opcode_list
       id 'TAB' field usr_tabl-sys.
    Internal table     usr_tabl

  • How to Find the length of Infosource?/

    Hi BW Guru's,
    How to Find the length of Infosource?
    Thanks
    Bhima Chandra Sekhar G

    Hi Bhima,
    You can look up the transfer structure (extract structure) in table ROOSOURCE in the active version of the DataSource and determine its size via SE11 (DDIC) -> Utilities -> Runtime object -> Table length.
    Hope it helps!
    Bye,
    ROberto

  • How to find out if LOB is stored "IN ROW"?

    Hi,
    If I have a compressed secuerfile LOB defined as "enable storage in row", is there any way to find out how many LOBs are stored in the table segment and how many where moved "out" in the lobsegment due to exceeding the approx. 4000 byte limit?
    If I haven't defined the question clearly enough, please let me know.
    Thanks in advance for any answer and regards,
    Jure

    Maybe I didn't explain the question well. I didn't ask how to find out from the data dictionary whether the LOB is defined as "enable storage in row" or "disable storage in row". I asked how to find out how many LOBs (LOB instances) are stored "in row" (in the table segment) and how many in the lobsegment, given that the LOB is defined as "ENABLE STORAGE IN ROW" with enabled compression.
    If I write the question in another way:
    Suppose I have a heap table with a LOB column defined as SECUREFILE COMPRESS HIGH, e.g.:
    CREATE TABLE test1 (id INTEGER, test_b BLOB)
    TABLESPACE USERS
    LOB (test_b) STORE AS SECUREFILE (
      TABLESPACE USERS
      COMPRESS HIGH  
      ENABLE STORAGE IN ROW
      CHUNK 8192
    )There are 1000 rows of data in the TEST1 table. The data length in the test_b BLOB varies from 100 bytes to 1MB, so some of those BLOBs are stored in the table segment (those with size approx. smaller than 4000bytes as described here http://download.oracle.com/docs/cd/E11882_01/appdev.112/e18294/adlob_tables.htm#sthref320) and some are stored in the lobsegment. My question is, how to find how many LOBs are stored in the table segment and how many are stored in the lobsegment due to exceeding approximately 4000 bytes (4000 bytes being the limit where the LOB is moved out of the table segment).
    The obvious answer could be to check the size of the LOB and if it is less than 4000 bytes (actually less than the size reported by the DBMS_LOB.GETCHUNKSIZE function) and based on that know where the LOB data is stored, but there are two problems with that approach:
    - how to account for data compression
    - even if the lob is defined as "ENABLE STORAGE IN ROW" and it's less than 4000 bytes in size, it could still be stored out of the table segment: http://download.oracle.com/docs/cd/E11882_01/appdev.112/e18294/adlob_tables.htm#ADLOB45273 : "If you update a LOB that is stored out-of-line and the resulting LOB is less than approximately 4000 bytes, it is still stored out-of-line."
    I hope I asked clearly this time.
    Regards,
    Jure

  • How to find number of lines in an internal table

    Dear all,
    how to find number of records present in an internal table.

    DESCRIBE TABLE
    Syntax
    DESCRIBE TABLE itab [KIND knd] [LINES lin] [OCCURS n].
    Extras:
    1. ... KIND knd
    2. ... LINES lin
    3. ... OCCURS n
    Effect
    This statement determines some properties of the internal table itab and assigns them to the specified variables. The various additions enable you to determine the table type, the number of currently filled rows and the initial memory requirement.
    In addition, the system fields sy-tfill and sy-tleng are filled with the current number of table rows and the length of a table row in bytes.
    Notes
    For detailed information about an internal table, you should use the methods of RTTS of the DESCRIBE TABLE statement.
    Without the specification of an addition, the statement DESCRIBE TABLE only sets the system fields sy-tfill and sy-tleng.
    Addition 1
    ... KIND knd
    Effect
    The table type of the internal table itab is determined and a corresponding one-digit identification is assigned to the data object knd. A character-type data type is expected for the data object. The identifications are "T" for standard tables, "S" for sorted tables and "H" for hashed tables. These values are also defined as constants sydes_kind-standard, sydes_kind-sorted, and sydes_kind-hashed in the type group SYDES.
    Addition 2
    ... LINES lin
    Effect
    The current number of table rows of the internal table itab is determined and is assigned to the data object lin.The data type i is expected for the data object.
    Note
    As of release 6.10, the current number of rows of an internal table can also be determined using the in-built function lines.
    Addition 3
    ... OCCURS n
    Effect
    The initial memory requirement defined during the creation of the internal table with the addition INITIAL SIZE or the obsolete addition OCCURS is determined and assigned to the data object n. The data type i is expected for the data object.
    Example
    Descending sorting of a generically typed internal table in a subprogram. Since sorted tables cannot be sorted in a descending order, the table type is checked to avoid an exception that cannot be handled.
    TYPE-POOLS sydes.
    FORM sort_descending CHANGING itab TYPE ANY TABLE.
      DATA tabkind(1) TYPE c.
      DESCRIBE TABLE itab KIND tabkind.
      IF tabkind = sydes_kind-standard OR
         tabkind = sydes_kind-hashed.
        SORT itab DESCENDING.
      ELSEIF tabkind = sydes_kind-sorted.
        MESSAGE '...' TYPE 'E'.
      ELSE.
        MESSAGE '...' TYPE 'E'.
      ENDIF.
    ENDFORM.
    DESCRIBE FIELD INTO
    Note
    This statement is for internal use only.
    It cannot be used in application programs.
    Syntax
    DESCRIBE FIELD dobj INTO td.
    Effect
    All characteristics of the field f, its components , sub-components etc. are displayed in the field td (type description). td has to be of the type SYDES_DESC, defined in Type Group SYDES. Because of this, the type group SYDES must be integrated into the ABAP-program with a TYPE-POOLS statement .
    The structure SYDES_DESC has two table-type components TYPES and NAMES:
    In TYPES, the tree structure of the type belonging to f is displayed. The components of a node are stored in the table TYPES in a continuous manner. Beginning and end of the line area that represents the components are stored in TYPES-FROM and TYPES-TO. The reference to the superior node can be found in TYPES-BACK. If no superior resp. subordinate node exists, then this is marked by the value 0 (For the relevance of further components, refer to the following sections).
    The names of components, types etc. are not stored directly in TYPES. Instead, the components TYPES-IDX_... hold an index in the name table NAMES. The value 0 indicates that there is no reference to the name table.
    NAMES contains the possibly fragmented names in the component NAMES-NAME. If a name continues in the following line, this is indicated by an asterisk ('*') in the component NAMES-CONTINUE.
    The type description table (TYPES) not only stores information about the tree structure but also further information about the type of f resp. its components. This includes especially all information that can be determined using the usual additions to DESCRIBE FIELD. In detail, TYPES contains the following columns:
    IDX_NAME
    Component Name
    IDX_USER_TYPE
    Name of a user-defined type, i.e., a type that was defined through its TYPES-statement. Derived types (... TYPE A-B) and structures from the ABAP-Dictionary are not considered to be user-defined types.
    CONTEXT
    For user-defined types only: The context, in which the type is defined. Possible values are defined in the constant SYDES_CONTEXT of the type group SYDES. Please only use these constants to carry out a comparison. In detail, we distinguish between the following type contexts:
    SYDES_CONTEXT-PROGRAM: Program-global type
    SYDES_CONTEXT-FORM   : FORM-local type
    SYDES_CONTEXT-FUNCTION: FUNCTION-local type
    SYDES_CONTEXT-METHOD : METHOD-local type
    IDX_CONTEXT_NAME
    For user-defined types only:
    With a local context: The name of the FORM or FUNCTION, whose type was defined. The name of the associated program is then the first entry in the name table.
    With a global context: The name of the program in which the type was defined.
    IDX_EDIT_MASK
    Conversion routine from the ABAP-Dictionary, is in accordance with the addition EDIT MASK at simple DESCRIBE.
    IDX_HELP_ID
    Help-Id when referencing to fields from the ABAP-Dictionary
    LENGTH
    Internal length, corresponds to the addition LENGTH at simple DESCRIBE
    OUTPUT_LENGTH
    Output length, corresponds to the addition OUTPUT-LENGTH at simple DESCRIBE
    DECIMALS
    Number of decimal digits, corresponds to the addition DECIMALS at simple DESCRIBE
    TYPE
    ABAP-Type, corresponds to the addition TYPE at simple DESCRIBE
    TABLE_KIND
    A table type is stored here for the components which represent an internal table. The same values are returned as with the variant DESCRIBE TABLE itab KIND k. Components which do not represent a table get the return value set to SYDES_KIND-UNDEFINED (see type group SYDES).
    Example
    Example definition of the complex data type EMPLOYEE_STRUC:
    PROGRAM DESCTEST.
    TYPES: BEGIN OF name_struc,
             first  TYPE c LENGTH 20,
             last   TYPE c LENGTH 20,
           END OF name_struc,
           BEGIN OF absence_time_struc,
             day        TYPE d,
             from       TYPE t,
             to         TYPE t,
           END OF absence_time_struc,
           phone_number TYPE n LENGTH 20,
           BEGIN OF employee_struc,
             id         LIKE sbook-customid,
             name       TYPE name_struc,
             BEGIN OF address,
               street  TYPE c LENGTH 30,
               zipcode TYPE n LENGTH 4,
               place   TYPE c LENGTH 30,
             END OF address,
             salary_per_month TYPE p LENGTH 10 DECIMALS 3,
             absent           TYPE STANDARD TABLE OF absence_time_struc
                                   WITH NON-UNIQUE DEFAULT KEY,
             phone            TYPE STANDARD TABLE OF phone_number
                                   WITH NON-UNIQUE DEFAULT KEY,
           END OF employee_struc.
    You can determine the structure of the type EMPLOYEE_STRUC by collecting the type group SYDES as follows:
    TYPE-POOLS: sydes.
    DATA: employee TYPE employee_struc,
          td       TYPE sydes_desc.
    DESCRIBE FIELD employee INTO td.
    The following table shows a few selected columns of the type description table TD-TYPES. For a better overview, the names of the columns IDX_NAME, IDX_UERR_TYPE and IDX_EDIT_MASK have been shortened:
        |FROM| TO |BACK|NAME|UTYP|EMSK|TYPE
    |--||||||--
      1 |  2 |  7 |  0 |  0 |  2 |  0 |  v
      2 |  0 |  0 |  1 |  6 |  0 |  4 |  N
      3 |  8 |  9 |  1 |  7 |  5 |  0 |  u
      4 | 10 | 12 |  1 |  8 |  0 |  0 |  u
      5 |  0 |  0 |  1 |  9 |  0 |  0 |  P
      6 | 13 | 13 |  1 | 11 |  0 |  0 |  h
      7 | 17 | 17 |  1 | 12 |  0 |  0 |  h
      8 |  0 |  0 |  3 | 13 |  0 |  0 |  C
      9 |  0 |  0 |  3 | 14 |  0 |  0 |  C
    10 |  0 |  0 |  4 | 15 |  0 |  0 |  C
    11 |  0 |  0 |  4 | 16 |  0 |  0 |  N
    12 |  0 |  0 |  4 | 17 |  0 |  0 |  C
    13 | 14 | 16 |  6 |  0 | 18 |  0 |  u
    14 |  0 |  0 | 13 | 20 |  0 |  0 |  D
    15 |  0 |  0 | 13 | 21 |  0 |  0 |  T
    16 |  0 |  0 | 13 | 22 |  0 |  0 |  T
    17 |  0 |  0 |  7 |  0 |  0 |  0 |  N
    Please note that the entries in rows 6 and 7 represent internal tables (ABAP-Type h). There is always an entry for the corresponding row type (rows 13 and 17) to an internal table.
    The indices in the rows 5 to 7 refer to entries in the name table TD-NAMES. If you look, e.g., at row 3, you find the corresponding component name in TD-NAMES from row 7 (NAME) onward and the corresponding user type from row 5 (NAME_STRUC) onward.
    In the name table TD-NAMES you find the following entries. Note that the names SALARY_PER_MONTH and ABSENCE_TIME_STRUC are stored in two parts:
        |CONTINUE|NAME                   |CONTINUE|NAME
    |--|     -||--
      1 |        |DESCTEST            12 |        |PHONE
      2 |        |EMPLOYEE_STRUC      13 |        |FIRST
      3 |        |SBOOK-CUSTOMID      14 |        |LAST
      4 |        |==ALPHA             15 |        |STREET
      5 |        |NAME_STRUC          16 |        |ZIPCODE
      6 |        |ID                  17 |        |PLACE
      7 |        |NAME                18 |   *    |ABSENCE_TIME_ST
      8 |        |ADDRESS             19 |        |RUC
      9 |   *    |SALARY_PER_MONT     20 |        |DAY
    10 |        |H                   21 |        |FROM
    11 |        |ABSENT              22 |        |TO

Maybe you are looking for