Which is better storing string values in Map or String buffer

Hi,
I have a store a 10 string values in a cookie. Do i use a String buffer and append all values or put it in a hash map.
If i put in a string buffer i have to use a string tokenizer to loop and extract the values., but if i am using a map then
retrieval will be easier, but in terms of memory management, which is better. as i have to create this cookie for every unique IP hitting my site.
Thanks,
Viiveek

viiveek wrote:
I have a store a 10 string values in a cookie. Do i use a String buffer and append all values or put it in a hash map.
If i put in a string buffer i have to use a string tokenizer to loop and extract the values., but if i am using a map then
retrieval will be easier, but in terms of memory management, which is better. as i have to create this cookie for every unique IP hitting my site. In terms of memory management, StringBuffer could potentially be better as there is no need to keep key objects in memory.
That doesn't make it a good idea. The bytes of memory you'd lose by using a Map would be made up by the fact that Map was expressly made for storing key/value pairs. Memory management should be about the 200th factor you should consider.

Similar Messages

  • Need help - ResourceBundle - formated string value (and multi-line string)

    Hi
    Can I put a value for key on many rows and formatted??
    Ex.: Into a file properties can I put
    key =
    My
    name
    is
    JTonic
    When I try to get the value for key, I get "". Can I get "My name is JToniC" ???
    Thx in advance.

    http://java.sun.com/j2se/1.4.2/docs/api/java/util/Properties.html#load(java.io.InputStream)
    The logical line holding all the data for a key-element pair may be spread out across several adjacent natural lines by escaping the line terminator sequence with a backslash character, \.

  • Which is better String null or should i initialize to blank ?

    Hi
    I am persisting one string in coherence which can be null for few cases. so putting null or blank which is better in coherence ?

    Assignment "null" for String references is good because Coherence will use less space of storage during serialization. It other terms, this is good for performance during replication and synchronization.
    Cheers,
    Ricardo Ferreira

  • Better technique null values

    Which is better, from the following?
    if method
    String studentIdParam = request.getParameter("studentId");
    long studentId = 0
    if(studentIdParam !=null)
        studentId = Long.parseLong(studentIdParam);exception method
    long studentId = 0;
    try{
       studentId = Long.parseLong(request.getParameter("studentId");
    }Exception e{}

    aksarben wrote:
    If a null student ID is harmless, i might be tempted to go with Door number 1.In both options, studentID is declared 0 (which may/may not change depending on the request parameter), so if a studentID of 0 is harmless then sure.
    Personally, I wouldn't use either. I would either declare the long studentID inside the try/catch block, or if it needed to be in a bigger scope, I'd declare it outside but not initialize it and do my null checks as needed.

  • 12.4 Beta, Error: Could not find a match for std::_Tuple_impl 0, std::string && ::_Tuple_impl(std::tuple std::string &&

    Hi,
    would you guys say code that compiles fine without -std=c++11 should also compile *with* -std=c++11?
    raider@sol112_x86:/tmp $ CC -V
    CC: Sun C++ 5.13 SunOS_i386 Beta2 2014/06/17
    raider@sol112_x86:/tmp $ CC buggy.cc  
    raider@sol112_x86:/tmp $ CC -std=c++11 buggy.cc         
    Error: Could not find a match for std::_Tuple_impl<0, std::string &&>::_Tuple_impl(std::tuple<std::string &&>, std::string ) needed in std::tuple<std::string &&>::tuple<std::string, void>(std::string &&).
    "/opt/SolarisStudio12.4-beta_jul14-solaris-x86/lib/compilers/CC-gcc/include/c++/4.8.2/tuple", line 868:     Where: While instantiating "std::tuple<std::string &&>::tuple<std::string, void>(std::string &&)".
    "/opt/SolarisStudio12.4-beta_jul14-solaris-x86/lib/compilers/CC-gcc/include/c++/4.8.2/tuple", line 868:     Where: Instantiated from std::forward_as_tuple<std::string>(std::string &&).
    "/opt/SolarisStudio12.4-beta_jul14-solaris-x86/lib/compilers/CC-gcc/include/c++/4.8.2/bits/stl_map.h", line 485:     Where: Instantiated from non-template code.
    1 Error(s) detected.
    raider@sol112_x86:/tmp $ cat buggy.cc
    #include <map>
    #include <string>
    typedef std::map<std::string, std::string> StrStrMap;
    int main(void)
        StrStrMap dict;
        dict["bug"] = "feature";
        return 0;

    C++11 is approximately a superset of C++03. If you write in the common subset, the code will compile in any mode. For example, a basic hello-world program
    #include <iostream>
    int main() { std::cout << "Hello, world!\n"; }
    will compile and run as C++98/03, as C++11, as C++14, and I'm sure will also work with the next standard, planned for 2017.
    But if you use syntax or library types and functions that are new in C++11, the code will not compile as C++03.
    In my previous post, I might have sounded too negative about compiling C++03 code in C++11 mode. If you have a C++03 program that is intended to be portable, and that works with different compilers on different platforms, chances are good that it will continue to work in C++11. The chances are very good that only minor modifications will be needed.

  • Calling Stored Procedure which returns single or multiple value

    Hi All Experts,
    I have written one stored procedure which is returning different
    integer values according to condition.I am calling this
    stored procedure through prepareCall() method then executeUpdate() method ,but it is always returning 1,not my desired value.
    Pl also tell me,if my stored procedure returns more than one value
    then how will i get those values in my java program?
    Pl help by writing some sample code.
    Thanx in Advance.
    Pradipto

    1) Create CallableStatement
    2) For each of returning value you have to call RegisterOutParameter()
    3) For others user setXXX() method depending on type of parameter
    4) call
    5) use vars registered through RegisterOutParameter() - all your values should be there
    Pavel

  • Which is better and why a = new String("AA") or a = "AA"

    Hi,
    Which is better and why
    String a = new String("AA") or
    String a = "AA"
    Does invoking a construtor waste memory? Please explain in detail.
    Thanks in advance
    Deepak

    > So in case "AA" not there in string pool,
    That is not correct.
    does new creates "AA" on string pool as well as heap memory?Yes. The literal "AA" points to a pooled String object. The new operator creates a new String object with the same character sequence ("AA"). You can verify this with a little code...
    String s = new String("AA");
    assert s != "AA";
    assert s.equals("AA");
    assert s.intern() == "AA";~

  • Which table is stored for O3defaults value?

    which table is stored for O3defaults value?

    Dear King Qi ,
    the default values that you create via transaction O3DEFAULTS are stored in two linked database tables:
    The header data is stored in table OIB_DEF_INDEX_GM
    The default set parameters itself are then stored table OIB_DEFAULTS.
    I hope this helps,
    Kind regards,
    Markus

  • Hi friends , in mapping program ,which is better one.why? explain me.

    1)In mapping program ,which is better one.why? explain me.

    Actually the sequence is
    Graphical
    Java
    XSLT
    ABAP
    graphical mapping can prove to be the simplest of all mappings and easy to so also as u have a mapping editor and standard functions available.
    when this becomes too complex v generally opt for java / xslt mappings.
    when u are much comfortable with abap u may also opt for abap mapping.
    still the choice depends on scenario. performance wise graphical and java mappings have
    good results (also depends on ur code in java mapping).
    refer this:
    Comparing performance of mapping programs:
    /people/udo.martens/blog/2006/08/23/comparing-performance-of-mapping-programs

  • How to define the boolean - String value mapping for SelectBooleanCheckBox?

    I have a SelectBooleanCheckBox component whose value is bind to a bean property of type String.
    <af:selectBooleanCheckbox text="State" label="State" id="sbc1"
    value="#{viewScope.myBean.stateText}" autoSubmit="true"/>
    The expected value for the Bean property is "Accepted" (for true) and "Rejected" (for false).
    Currently, the component return String value "true" for checked and "false" for unchecked.
    How do I set up the component so the boolean value can map to my expected String value?

    Sumit,
    Thanks for the response.
    I read that post too. However, I don't have any binding in my case because the component is bind to a bean property instead of an attribute of a view object.
    Without the binding in the page definition, I can't find a place to define the mapping between the Boolean value and the expected String value.
    Pricilla

  • Can't assign a string value to a member of type TEXT in Calculation Manager

    I can assign a string value to that member of type TEXT using a run-time prompt of type StringToNumber.
    Example: "My Text Member" = {string_rtp};
    However, I need to accompllish the same function without using a run-time prompts.
    I have a planning application and I know that text along with all other non-numeric
    values are stored on the relational side in the planning application schema.
    It seems reasonable to assume that if this can can accomplish
    with a run-time prompt that I could do also do it without a run-time prompt.
    What appears to be lacking is a function like:
    "My Text Member" = @StringToNumber(<String Literal>);
    Clearly, this is already being done "under the covers" for run-time prompts. If
    would appear to be a minor enhancement to expose such a function to developers.
    NOTE: I suppose you would also need to add new syntax/function to identify a string
    literal from say a member name. I'm wondering if this is the more difficult challenge
    from a product perspective????

    When executing a Calculation Manager rule in Planning, the run-time prompt (RTP) is populated by looking up the outline information present in the relational Planning application database. If the RTP is of type TEXT, the strings displayed in the member select are from the from the relational Planning application database too. Subsequently when executing the Rule, the RTP's value is in fact the record ID (a number) which is then saved into the appropriate intersection in Essbase.
    You need to bear in mind, the Rule is executed in Essbase. If Essbase needs to "write" a text, it would then need to connect to the Planning relational database to create a new record. The newly created record ID then needs to be feed back to Essbase, in order to store it in the appropriate intersection.
    What you are suggesting, comes with a big overhead causing Essbase and the rule to slow. Thus, the disadvantages outweighs the advantages.

  • How to align a String value to the right side inside a table column?

    Hi,
    I have a text view inside a table column which is mapped to a string attribute. I need to align the text in the text view to the right hand inside the table column. But its always getting aligned towards the left side. I have tried by setting the <b>hAlign</b> property of Element properties of Text View to <b>right / forced right</b> but still the text is getting aligned to the left side.
    How do I align the String values in Text View towards the right hand side inside a Table Column?
    Thanks and Regards,
    Sayan Ghosh

    Hello Sayan,
    if i do get it right, you are adding an TextView element to a Table Cell. Then you should consider setting aligment within the particular cell. By calling:
    YourCell.setHorizontalAlignment(CellHAlign.RIGHT)
    regards.
    mz

  • Doubt about  a null value assigned to a String variable

    Hi,
    I have a doubt about a behavior when assigning a null value to a string variable and then seeing the output, the code is the next one:
    public static void main(String[] args) {
            String total = null;
            System.out.println(total);
            total = total+"one";
            System.out.println(total);
    }the doubt comes when i see the output, the output i get is this:
    null
    nulloneA variable with null value means it does not contains a reference to an object in memory, so the question is why the null is printed when i concatenate the total variable which has a null value with the string "one".
    Is the null value converted to string ??
    Please clarify
    Regards and thanks!
    Carlos

    null is a keyword to inform compiler that the reference contain nothingNo. 'null' is not a keyword, it is a literal. Beyond that the compiler doesn't care. It has a runtime value as well.
    total contains null value means it does not have memory,No, it means it refers to nothing, as opposed to referring to an object.
    for representation purpose it contain "null"No. println(String) has special behaviour if the argument is null. This is documented and has already been described above. Your handwaving about 'for representation purpose' is meaningless. The compiler and the JVM don't know the purpose of the code.
    e.g. this keyword shows a hash value instead of memory addressNo it doesn't: it depends entirely on the actual class of the object referred to by 'this', and specifically what its toString() method does.
    similarly "total" maps null as a literal.Completely meaningless. "total" doesn't 'map' anything, it is just a literal. The behaviour you describe is a property of the string concatenation operator, not of string literals.
    I hope you can understand this.Nobody could understand it. It is compete nonsense. The correct answer has already been given. Please read the thread before you contribute.

  • Payload in String need Java mapping to IDOC structure

    Hi
    I have a payload in a field and that payload needs to  be mapped to IDOC sturcture. As per my understanding I will have to write java mapping for the same.
    I don't have any background of java, can anyone help me do this stuff or give me some inputs for the same.
    Regards
    Ria

    Dear Ria,
    Does the Source field consists of payload, then there must be original payload for which you have created Source Structure in XI right.
    I think your source structure look like this if I'm not wrong:
    <Data Type>
        < Field>
          <Field>
           <Field-Payload>
           </Field-Payload>
           </Field>
           </Field>
    </DataType>
    If this is so, you can split the values in the field by FCC. If your field consists of simple payload you can use String functions to extract the value and map it to IDOC field.
    Best Regards
    Praveen K

  • How to pass dynamically generated string value as array name in TestStand?

    Hi All,
              I have a string variable which holds an array name as its value. The string value is a dynamically generated one. Now my problem is how to retrieve the values within the array where as the array name is stored in a string variable.
    for eg:
    fileglobals.InfoName = "Array_Name" --> fileglobals.InfoName is a string variable, Array_Name is the array name generated dynamically and it is known only at run-time.
    Array_Name[0] = "a";
    Array_Name[1] = "b";
    Array_Name[2] = "c";
    In the above case, I have to retrieve the values of a, b and c
    Any help is greatly appreciated
    Thanks
    Arun Prasath E G

    Hi,
    Looking at your sequencefile.
    You seem to be trying to save into FlieGlobals.InfoName a string with the values of "FileGlobals.Info_0".."FileGlobals.Info_n" where n is the value of Parameter.TestSocket.Index.
    Then you are setting the value into FileGlobals.TempName from "StationGlobals.FileGlobals.Info_0" assuming Parameter.TestSocket.Index is 0.
    Is this correct?
    I realise this is a cutdown sequence file but you must make sure These variable actually exist in either FileGlobals or StationGlobals. Also with FileGlobals each SequenceFile has its own FileGlobals unless you have set the properties of the SequencFile to use a common FileGlobals.
    What was the precise error you was seeing as it will properly telling you what variable of property it can't find.
    Regards
    Ray Farmer
    Regards
    Ray Farmer

Maybe you are looking for

  • Controling the 'name' of a file download

    function openPDFWordTwo(thisObj,pdfURL){ //For Opening Word formTitleId = thisObj.id.substr(0,thisObj.id.lastIndexOf(':')) + ":hiddenFormTitle"; formTitle = document.getElementById(formTitleId).value; window.location = pdfURL;    return false;Here is

  • When will the Non-Admin problem be fixed?????

    When will the problem of non-admin accounts not able to see all flash content on web pages be addressed???

  • Business Graphics in ADS doesn't display on subsequent calls

    We have this bizarre problem with Business Graphics in ADS. We are embedding Business Graphics in an Adobe form and we find that the Business Graphics will not be displayed on second (subsequent) call(s) to the ADS, which can be simulated by clicking

  • Diff between at-new and on-change of in loop events

    diff between <b>at-new</b> and <b>on-change of</b> in loop events

  • Downloading 9iAS R2

    I am downloading 9iAS R2. I am using dowload accelator (a download manager) but it cannot do anything since the server is not resume supported. I don't think that anyone can download such big files without having some extra ordinary internet connecti