Effective way to copy substring without generating garbage

Hi,
I am trying to copy portion of STRING1 to STRINGBUFFER1.
STRINGBUFFER.append(STRING1.substring(from_index, to_index));
However, above method generates a String object, then copy its content to STRINGBUFFER, creating garbage.
Is there some way to do this without generating garbage? Of course, I know I can create a loop and copy one character at a time, but I am afraid that will be slow for huge strings. Thank you in advance.

Using bothe StringBuilder and StringBuffer there are multiple ways to do what you want.
Look at the API.
There are methods for appending char arrays or ranges of CharSequences to a StringBuffer.I am sorry I should have mentioned that I am using J2ME, not J2SE. I looked at the API, but could not find anything.
And yes, I am trying to avoid garbage as much as possible, because this code gets called quite often.
Thank you for feedback everyone. I'm still lost with this.

Similar Messages

  • Creating JAX-WS client without generating portable artifact

    Hey.
    Is there a way to create and call web service only knowing the wsdl location?
    Now I have been generating client from wsdl. But is there a way to do that without generating service classes to client from wsdl?

    yes, you can use the Dispatch api.

  • Is there a way to copy or back up contacts from my Ipod touch without using Itunes?

    Is there a way to copy or back up contacts from my Ipod touch without using Itunes?

    Are you sure that you can transfer contacts from the iPod to Skydrive?
    I would try the links that I previusly provided and try to get iTunes to see the iPOd so you can do everthing right.
    If you find a computer that can see the iPOd yu can update the iPod on that computer.  See:
    iOS 5: Updating your device to iOS 5
    Yu can make that your suncing computer by -
    - Transfering iTunes purchases:
    iTunes Store: Transferring purchases from your iPhone, iPad, or iPod to a computer
    - Connect the iPod and make a backup by right clicking on the iPOd under Dvices in iTunes and select Back Up
    - Restore from that backup. That will also update the iPod.

  • Is there a way to copy/paste text in Photoshop without keeping formatting?

    Hello,
    Is there a way to copy/paste text in Photoshop without keeping formatting (font, size, color, etc)?
    I found this feature very annoying.
    Is there a way to turn it off?
    Thanks.

    You can use this simple workariound:
    copy the desired text  and paste it in a simple text editor app like notepad (win) or textedit (mac).
    Then copy this unformatted text and paste it in photohop.

  • By mistake i ereased my mackbook pro's disk. and when is restared it recovery page opened. and i did not purchase the osx mountain lion. do i have any other way to recory it without purchasing the copy of osx. can i do it using a usb having image file of

    by mistake i ereased my mackbook pro's disk. and when is restared it recovery page opened. and i did not purchase the osx mountain lion. do i have any other way to recory it without purchasing the copy of osx. ?can i do it using a usb having image file of mountain lion?

    Did you buy your machine second-hand? That's really the only way you would have to purchase OS X 10.8.x from the App Store... but, yes, if you have a USB thumb drive with a bootable installer (such as made with Lion DiskMaker) you can boot from that and reinstall OS X.
    Clinton

  • Is there a way to copy the effects on a fader to another project?

    I'm in Logic 8 now ... wondering if there is a way to copy the effects plug-ins (assigned to a particular track/fader in one project) to a track/fader in another project?
    Besides saving the 'effected' project to a new name and importing the audio tracks from the other project ...
    Ben

    Thank you sereen, so simple.
    Much appreciated.
    Ben

  • What is the best way to copy data....

    Hello friends,
    What could you think is the best way to copy this data ? :
    - I have two identical databases (Oracle 9i)
    - I want to migrate the data of 90 tables (all tables begin with the same string, i.e. 'TAB') from Database1 to database2.
    - There are integrity constraints, referentials, etc.
    I'd like to generate a script to automate/accelerate the process.
    So, I'm thinking on the following:
    - Disable all the constraints in Database2.
    - Connect to Database 1 and generate a script with the 'inserts' using TOAD (or another similar application)
    - In a Database 2 session, execute the script...
    Of course if I use TOAD I can't generate an unique script to do this process in one step so...
    Any better idea? (Using export/import, ... or some script you have...)
    Thanks.
    Jose.

    Use exp and imp. It works... seriously! And you don't need to drop the user/schema. But don't take my word, run an example...
    On Database 1
    First let's create a couple of tables with referential integrity to each other to make sure exp/imp can handle it...
    SQL> create table t1 (t1_id number constraint pk_t1 primary key, t2_id number);
    Table created.
    SQL> create table t2 (t2_id number constraint pk_t2 primary key, t1_id number);
    Table created.
    SQL> alter table t1 add constraint fk_t1_t2 foreign key (t2_id) references t2 (t2_id);
    Table altered.
    SQL> alter table t2 add constraint fk_t2_t1 foreign key (t1_id) references t1 (t1_id);
    Table altered.
    SQL> insert into t1 (t1_id, t2_id) values (1, null);
    1 row created.
    SQL> insert into t2 (t2_id, t1_id) values (2, 1);
    1 row created.
    SQL> update t1 set t2_id = 2 where t2_id is null;
    1 row updated.
    SQL> commit;
    Commit complete.
    SQL> select * from t1;
         T1_ID      T2_ID
             1          2
    SQL> select * from t2;
         T2_ID      T1_ID
             2          1
    SQL> select table_name, constraint_name, constraint_type, r_constraint_name from user_constraints
      2  where table_name in ('T1','T2');
    TABLE_NAME                     CONSTRAINT_NAME                C R_CONSTRAINT_NAME
    T1                             PK_T1                          P
    T1                             FK_T1_T2                       R PK_T2
    T2                             PK_T2                          P
    T2                             FK_T2_T1                       R PK_T1
    SQL>
    Now let's export those tables. You can build a parfile manually or even spool it from a sql script with the names of all tables you need to export...
    $ cat parfile.txt
    tables=(\
    t1,\
    t2
    $ exp rc/pwd parfile=parfile.txt file=db1.dmp log=db1.log
    Export: Release 10.1.0.3.0 - Production on Mon Jan 9 20:49:17 2006
    Copyright (c) 1982, 2004, Oracle.  All rights reserved.
    Connected to: Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - Production
    With the Partitioning, OLAP and Data Mining options
    Export done in UTF8 character set and UTF8 NCHAR character set
    About to export specified tables via Conventional Path ...
    . . exporting table                             T1          1 rows exported
    . . exporting table                             T2          1 rows exported
    Export terminated successfully without warnings.
    On Database 2
    Copy your .dmp file to Database 2
    Import
    $ imp rc/pwd full=y file=db1.dmp log=db1_imp.log
    Import: Release 10.1.0.3.0 - Production on Mon Jan 9 20:51:15 2006
    Copyright (c) 1982, 2004, Oracle.  All rights reserved.
    Connected to: Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - Production
    With the Partitioning, OLAP and Data Mining options
    Export file created by EXPORT:V10.01.00 via conventional path
    import done in UTF8 character set and UTF8 NCHAR character set
    . importing RC's objects into RC
    . . importing table                           "T1"          1 rows imported
    . . importing table                           "T2"          1 rows imported
    About to enable constraints...
    Import terminated successfully without warnings.
    All data is there...
    SQL> select * from t1;
         T1_ID      T2_ID
             1          2
    SQL> select * from t2;
         T2_ID      T1_ID
             2          1 All constraints are there...
    SQL> select table_name, constraint_name, constraint_type, r_constraint_name from user_constraints
      2  where table_name in ('T1','T2');
    TABLE_NAME                     CONSTRAINT_NAME                C R_CONSTRAINT_NAME
    T1                             PK_T1                          P
    T1                             FK_T1_T2                       R PK_T2
    T2                             PK_T2                          P
    T2                             FK_T2_T1                       R PK_T1It does work!

  • An effective way to compress Large Object Heap

    I think I've found an effective way to compress LOH: 
    If CLR always alloc every large object at the beginning of a RAM page(usually 4KB per page),then the large object heap(LOH) can be compressed without much
    cost: CLR can compress LOH by modifying RAM page table and TLB instead of copying data. If so, small fragmentation maybe still exist (less then a memory page size per fragment), but there would be no large fragmentation, and compressing would be very fast
    because of no copying. To do this, OS support may be needed, fortunately Windows OS and Visual Studio are both Microsoft's softwares, so Microsoft can implement this at least on Windows.

    I suspect that this technique is already used in a 3rd party implementation of Java. It was briefly mentioned in a discussion about alternative GCs for CoreCLR:
    https://github.com/dotnet/coreclr/issues/430
    In any case, feel free to open a specific issue in the CoreCLR GitHub repository about this. Implementing an entirely new GC is a lot of work but simply improving the existing one might be another story. Though the fact that it requires kernel
    support doesn't help, it may be done but it will have to wait until the kernel guys implement support for it and that will take time. There may also be legal problems if someone has a patent for such a technique.
    Regarding performance: modifying page tables has a certain cost. It's possible to find that for smaller blocks it's faster to just copy the block than to modify the page tables. An implementation would probably have to employ a mix of memory copying and
    page table modification and in that case you don't even need to require that objects are allocated on a page boundary. Keep in mind that it's not required to deal with one object at a time, there may be consecutive live objects that can be copied in one go.
    As for Joel ramblings, well:
    "I have a master in computer science and know the speed of the algorithm of compacting a large heap."
    Given that you have a history of misleading/inaccurate/confusing claims such a statement is priceless. I suppose that during your master courses you were never taught basic data structures and as result you don't know that hashtable searches are O(1)
    and that sorting does help with searching:
    https://social.msdn.microsoft.com/Forums/en-US/09a3116a-9626-401f-8c45-c0e8b09da69c/fastest-search-algorithm?forum=csharpgeneral
    In this particular case you seem to confuse the term heap as used in GC with the heap data structure. Great.
    Thank you! I have opened a specific issue in the CoreCLR GitHub repository about this: https://github.com/dotnet/coreclr/issues/555

  • Is there a way to copy all my PDfs in ibooks on my iPad?

    Because I'm still sorting out an issue with ibooks on the iMac renaming files so they do not match the names on my iPad, I am wondering if there is a way to copy all the pdfs I have in ibooks on my ipad (without doing each one, one at a time) so I can save a copy in Evernote or dropbox so when I sync and update shortly, I don't loose what I have?
    Thanks for any help you can offer.
    Michelle

    Thank you.Ok say for e.g.
    500 video files imported in fcpx
    800 clips extracted from these obviously on the timeline and joined/compounded according to their content in say 15 layers according to 15 instruments used ,so now just to see the entire usable footage ....
    now one 7 minute song sequence has to be made where bits would be simultaneously taken from these 15 layers as all instruments are playing simultaneously
    these shots are not more than 2 secs each according to the beat........
    when I try to work with these 15 layers as well as the Final primary layer that I'm making in the same timeline my fcpx becomes slow
    but when I drag individual layer to individual timelines it is fine so that is the only option
    but now for every 2 second bit I have to go back to the 15 layered timeline and find one single suitable shot
    So I was wondering is there a way to be able to see these layers and clips on the timeline in the browser in a systematic fashion like the way we get with keywords  ?
    and keywords can only be used in the imported clips already in the browser ,and not after we drag it on the timeline.....
    Till now I think exporting and importing back is the only option ...but is there another work around ?

  • In STO, system allowing to make invoice without generating PGI

    Dear All,
    We are using SAP ECC 6.0, in stock transfer STO - Delivery - PGI - Invoice - excise invoice, this procedure we are using. Now error which has been noticed is that without generating  PGI, system is allowing to make excise invoice in the system. Requirement is that system would not allow to make invoice without generating PGI in the system. Anybody can help in this matter.
    Thanks in advance.
    Madhukar Mittal

    Hi,
    go to Txn.VTFL Under Header chose the item category and change the copying requirements change from 11 to 3.
    Regards
    GK.
    Edited by: Gnana Kumar on Oct 7, 2010 7:01 AM

  • Is there a way to copy & paste a clip from the timeline in one project in to another project?

    Hello Popular Premiere Pontificaters,
    I am using Premiere 6 on a Windows 7 machine.
    Is there a way to copy and paste a clip from the timeline in one project in to another project?... I can copy my clip, but when I open the other project, it will not allow me to paste it in there... but I am able to copy and paste a clip within a single project.  I tried everything... pasting in to a new video track and pasting in to an existing video track in the second project, but the paste option simply isn't there when I open the second project.
    And if Premiere itself will not allow me to do this in any way, will a copy-paste clipboard type of accessory app allow me to do this?... if so, which is the best, trustworthy copy-paste app that is malware free?
    Thanks,
    digi

    Hi Bill Hunt,
    I just read the page that you provided about "Handles"... thanks allot for that ARTICLE.  In your article and the subsequent article HANDLES, "Transitions Overview: applying transitions" linked from your article, it indicates (in PrE and PrPro anyway - I'm in Premiere 6) that transitions can be applied to non-Video 1 tracks... the paragraph below is a quote from that "Transitions Overview: applying transitions" article...
    "Whatever is below the transition in a Timeline panel appears in the transparent portion of the transition (the portion of the effect that would display frames from the adjacent clip in a two-sided transition). If the clip is on Video 1 or has no clips beneath it, the transparent portions display black. If the clip is on a track above another clip, the lower clip is shown through the transition, making it look like a double-sided transition."
    So this indicates that transitions can be applied to non-Video 1 tracks since it is referring to content in tracks beneath a transparent fade that would show through... and only non-Video 1 tracks can be transparent and have other clips "beneath" them in the timeline, right?
    In the screenshot sample in your article at this LINK, I see the handles (referred to as B and E) and I can see in my monitor window how those handles would be represented by the two little bracket symbols {  }  ... you can see how they appear in my monitor window in Premiere 6 in this screenshot, and below, from a different thread that isn't related to this topic.
    But I'm still trying to figure out how the handles can be applied in the non-Video 1 tracks in the timeline to insert a transition (cross-dissolve) between two clips.
    Can you advise me on this?... I posted a separate thread HERE on this topic, but I haven't got any further with finding an answer.
    Thanks so much for your article,
    digi

  • Is there a way of copying music from the ipod

    my pc got wiped so i need a way of copying music from my ipod to itunes is there a way?

    Connect your iPod to your computer. If it is set to update automatically you'll get a message that it is linked to a different library and asking if you want to link to this one and replace all your songs etc, press "Cancel". Pressing "Erase and Sync" will irretrievably remove all the songs from your iPod. Your iPod should appear in the iTunes source list from where you can change the update setting to manual and use your iPod without the risk of accidentally erasing it. Also when using most of the utilities listed below your iPod needs to be enabled for disc use, changing to manual update will do this by default. Check the "manually manage music and videos" box in Summary then press the Apply button: Managing content manually on iPod
    Once you are safely connected there are a few things you can do to restore your iTunes from the iPod. If you have any iTunes Music Store purchases the transfer of purchased content from the iPod to authorised computers was introduced with iTunes 7. You'll find details in this article: Copying iTunes Store purchases from your iPod to a computer
    The transfer of content from other sources such as songs imported from CD is designed by default to be one way from iTunes to iPod. However there are a number of third party utilities that you can use to retrieve the music files and playlists from your iPod. You'll find that they have varying degrees of functionality and some will transfer movies, videos, photos, podcasts and games as well. Have a look at the web pages and documentation, this is just a small selection of what's available, they are generally quite straightforward. You can read reviews of some of them here: Wired News - Rescue Your Stranded Tunes
    TuneJack Windows Only
    iPod2PC Windows Only
    iGadget Windows Only
    iDump Windows Only
    SharePod Windows Only
    iRepo Mac and Windows
    iPodRip Mac & Windows
    YamiPod Mac and Windows
    Music Rescue Mac & Windows
    iPodCopy Mac and Windows
    There is also a manual method of accessing the iPod's hard drive and copying songs back to iTunes on Windows or a Mac. The procedure is a bit involved and won't recover playlists but if you're interested it's available at this link: Two-way Street: Moving Music Off the iPod
    Whichever of these retrieval methods you choose, keep your iPod in manual mode until you have reloaded your iTunes and you are happy with your playlists etc then it will be safe to return it auto-sync. I would also advise that you get yourself an external hard drive and back your stuff up, relying on an iPod as your sole backup is not a good idea and external drives are comparatively inexpensive these days, you can get loads of storage for a reasonable outlay.

  • Different ways to copy data between two schemas in one instance

    Hi there,
    I am searching a good way to copy data between two schemas in the same instance.
    Both schemas have an identical structure such as triggers, tables, views and so on. The only difference is the purpose: one is the productivity system and one is for development.
    I looked at datapump but I do not explicit want to export / import. I want to keep the data in the productivity schema as well as copy it to the other schema. Any ideas? I found out there is a copy statement but I dont't know how that works.
    Thank you so far,
    Jörn

    Thank you for your replies!
    I also thought of creating a second instance for development and move the dev - schema to it. I just don't know whether our server can handle both (performance?). Anyway the idea is to have a possibility to quickly rebuild the data inside a schema without indixes or triggers, just pure data. I thought the easiest way would be to copy the data between the schemas as they are exactly the same. However if you tell me DataPunp is the best solution i won't deny using it :).
    When you export data a file is created. does that also mean that the exported data is deleted inside the schema?
    best regards
    Jörn
    Ps: Guido, you are following me, aren' t you? ;-)

  • Is there any way to copy proxy filed structures to ABAP field structure?

    Hi All,
    We are getting message from  XI using inbound proxy and sending response asynchronously by outbound proxy.
    my question: " is there any way to copy or to move incoming proxy fields to ABAP backend fields?"
    for ex: we are getting Name structure from proxy wit fields firstname and lastname.
    and proxy will generate some structures for name. backend ABAP system will have structure name with two fields having fname and lname as data elements.
    so how can we directly move proxy fields to ABAP fields? ( here in example there are only two fields but real scenario we will have thousands of fields for which we cannot map manually from proxy fields to ABAP fields.)
    please help me in this regard.
    Thanks in advance.
    Regards,
    Ujwalkumar

    Hi Ujwalkumar,
    if you have control over the proxy:
    Create your interface at XI like the structure in backend system. Same structure and same fieldnames. If you regenerate your proxy you can use abap order "MOVE CORRESPONDING" to map all fields.
    Regards,
    Udo

  • Effective way from AE to FCP

    Is there any effective way to transfer file from FCP to AE or AE to FCP beside export a quicktime to AE and render back to FCP? tjx

    Is there any effective way to transfer file from FCP to AE or AE to FCP beside export a quicktime to AE and render back to FCP?< </div>
    Automatic Duck.< </div>
    While true, AutoDuck is expensive overkill for most of us. I've been using After Effects with Media 100 and FCP for more than a decade without ever needing a tool like AD (although M100 did have something similar built right into it, I just didn't use it very often).
    Moving FCP sequences in and out of AE requires sophisticated tools like AutmaticDuck. Moving a simple video file in and out of AE is a drag and drop situation. Mostly.
    Try telling us what you're trying to do.
    bogiesan

Maybe you are looking for

  • What is the max number of SMS & MMS messages that the iphone can store?

    iOS currently has a limit of 100 phone calls that can be stored in the call log. Is there a similar limit for SMS or MMS messages? If so, what it is? Where is this documented?

  • Unsupported key or value

    Hi, I'm getting the following error when I try to retreive an object from the cache: 11:10:47,835 ERROR [STDERR] java.lang.IllegalArgumentException: Unsupported key or value: Key=1391631, Value=PartyImpl[PartyImpl[PartyImpl[objectId=61 380,entityId=6

  • Center image in a display

    Hi, In my project, I have to display 2D images in a display indicator. I change with succes the zoom factor, so one dimension of the image (the largest) fit with the display. For the other dimension (the smallest) I would like to place the image at t

  • Smartform Pages Problem

    Hi, I have developed a Smartform and that is working fine with all values that form have terms and conditions and subtotals if i have one page i need to display in the first page all the terms and conditions if i  have more than one page i need to di

  • I cant open cc files in cs6

    help somebody, if you have a solution, please help. i cant open a template from Ae 12.2 in 11.0.2 does somebody know how to fix this ? thx