Some query regarding Iterator

Hi friends,
I have a doubt like with collections we always use Iterator to iterate through, but suppose if we want to add more element to collection while iterating, how can we do so?
waiting foe reply.
Thanks

CookBookJ wrote:
Yes,this is not possible for you to add element while iterating.That depends entirely on the iterator.
Most of the standard iterators allow you to remove an element from the collection you're iterating over. However, you must use the .remove() method on the Iterator to do this, otherwise you will get a ConcurrentModificationException.
ListIterators also let you add elements to the collection (among other list operations). Again, you must use the methods on the ListIterator to modify the collection while you're iterating.

Similar Messages

  • Some query regarding mark(readlimit) in inputstream

    Hi
    I am new learner of java. I have some query for mark(readlimit) in inputstream, i want to use it for my usecase.
    The usecase is:-
    I want to read a big file (10 mb) using FileInputStream using multiple threads in parallel. Each thread is give a FileInputStream for the same file to read only 1 mb. So I created 10 threads, and give me FileInputStream to read stream in parallel.
    I want that 1 thread read 1st mb data, second thread second next mb part and so on.
    To do that, I used Skip and mark(readlimit ) method. i created the array of fileinputstream in the following way.
    <code_tags>
    int totalsegment=(int)(file.length() / MAX_SEGMENT_SIZE)+1;
    FileInputStream[] fis = new FileInputStream[totalsegment];
    for(int i=0;i<totalsegment;i++){
    fis=new FileInputStream(file);
    fis[i].skip((int)MAX_SEGMENT_SIZE*i);
    fis[i].mark((int)MAX_SEGMENT_SIZE*(i+1));
    createFile(fis[i], "File" + i);
    public static File createFile(InputStream in, String sfilename) throws FileNotFoundException, IOException {
    InputStream byteArrayInputStream = in;
    String outStr = byteArrayInputStream.toString();
    File newFile = new File(sfilename);
    FileOutputStream fos = new FileOutputStream(newFile);
    int data;
    while ((data = byteArrayInputStream.read()) != -1 ) ) {
    char ch = (char) data;
    fos.write(ch);
    fos.flush();
    fos.close();
    return newFile;
    </code_tags>
    I am expecting that 10 files are created with 1 mb each. But this is not the case. I am able to skip the starting part of data while reading, but it always read till end. I am expecting, it will read till the readlimit is set for particular fileinputstream
    Am I doing something wrong ? Any help - how can I do that using inputstream?
    Thanks
    Java learner

    804320 wrote:
    ByteArrayInputStream would require to read the 1 gb data in bytes and creating stream from it.Hunh? No it wouldn't.
    In any case, I suspect you're overthinking this. All you appear to want is to split a file into chunks, so you only need to skip over the first n (or n*chunkNumber) bytes, then read n bytes, and a simple InputStream will allow you to do that.
    The experts here may be able to tell you if there's any advantage to using a RandomAccessFile, but marking is generally only used if you need to return to a particular point in a buffer in order to re-read it. It also requires that the buffer be large enough to contain the position to return to, which in your case may be enormous.
    Simple code is usually the best.
    Winston

  • Some Query Regarding SAP NetWeaver Features

    Hi friends,
        Can u give me some simple questions answers regarding NetWeaver :
    1> What is the oldest and latest versions of NetWeaver and in which SAP versions it runs ?
    2> Whether we can write Report(Type 1) or Module Pool (Type M) programs in NetWeaver ?
    3> Will we only see the NetWeaver output in Browser ( like this SDN Community Network ) or can view the output also through SAPGUI.
    4> What is current scope of NetWeaver for Job prospect against SAP ABAP?
    5> The basic type of works handled by NetWeaver ?
    6> And whether it a different module in SAP like SD, MM , or new programming environment like ABAP, or SAP new technology like BW ?
    Please reply back to me.
    Thanks & Regards,
    Sujoy
    [email protected]

    Hi Sujoy,
    1. the oldest version means Netweaver 2004 is the first and old version than the next release of Netweaver 2004s the latest vesion is Netweaver 7.0
    2.u can checkout in SDN for assistance
    3.no can u brief ur question ,as my point of view this seems to be different  u cant view those things in SAGUI
    4.can u brief the question
    5.Netweaver is the concept merging the things with Java ,a netweaver has two stacks as ABAP and as JAVA ,java engine looks for the development environment for the portals and it acts along with the ABAP stack as a frontend web pages to connect the r/3 as the backend -Refer this note no:864172
    6.please to know more about http://help.sap.com/saphelp_nw04/helpdata/en/start.htm
    reward points welcome for the useful tips!
    regards,
    S.Rajeshkumar

  • Have some doubt regarding the  weblog (Lookup's in XI made simpler)

    Hi All,
    I have created the same scenario as mentioned in Siva's weblog (Lookup's in XI made simpler).
    I having some doubts regarding the scenario, it will be great if you help me to resolve the same.
    I am having a file-file scenario where I need to do lookup in database(MS-Access)  through mapping.
    The standard file-file scenario is in place and in addition I have created a receiver jdbc channel . I  have also created the receiver agreement for the same in the cofiguration.
    While creating the receiver agreement you have to specify the interface name which includes the message type…I have specified the normal format which we specify while configuring the jdbc receiver adapter.
    In the message mapping I have created a advance user defined function as mentioned in your weblog which calls my receiver jdbc channel.
    I have also specified the select query to be executed in the mapping program.
    While testing I am getting the following error
    Cannot produce target element /ns0:Role_MT/URole. Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd
    <b>Can you please suggest me what all I need to do in addition to the file-file scenario for this lookup scenario to work.</b>
    Thanks and Regards
    Rahul

    Hi,
    Following is my user defined function
    //write your code here
    String Query = "";
    Channel channel = null;
    DataBaseAccessor accessor = null;
    DataBaseResult resultSet = null;
    Query = "Select URole from  Lookup where UName = '  " + UName[0] + "  ' and UPassword = '  " + Pwd[0] +" '  ";
    try{
    channel = LookupService.getChannel("DB_service","JDBC_channel_receiver");
    accessor = LookupService.getDataBaseAccessor(channel);
    resultSet  = accessor.execute(Query);
    for(Iterator rows = resultSet.getRows();rows.hasNext();){
    Map rowMap = (Map)rows.next();
    result.addValue((String)rowMap.get("URole"));
    catch(Exception ex){
    result.addValue(ex.getMessage());
    finally{
    try{
    if (accessor!= null) accessor.close();
    catch(Exception ex){
    result.addValue(ex.getMessage());
    Thanks and Regards
    Rahul

  • Query regarding the data type for fetcing records from multiple ODS tables

    hey guys;
    i have a query regarding the data type for fetcing records from multiple ODS tables.
    if i have 2 table with a same column name then in the datatype under parent row node i cant add 2 nodes with the same name.
    can any one help with some suggestion.

    Hi Mudit,
    One option would be to go as mentioned by Padamja , prefxing the table name to the column name or another would be to use the AS keyoword in your SQL statement.
    AS is used to rename the column name when data is being selected from your DB.
    So, the query  Select ename as empname from emptable will return the data with column name as empname.
    Regards,
    Bhavesh

  • Query regarding G/LAccounts in psoting

    Hi Experts,
    I have one query regarding PCP0.
    After executing PCP0,If We double click on the posting document we can see the number of G/L accounts in that posting Document.If we double click on each G/L Account it shows all the revision information indetail for all payments cumulated into that particular G/L Account.
    Some of the G/L's are appearing as single line in the posting document and if we double click for the revision information it is showing all the Wagetypes with personnel numbers and the total of each wagetype.
    Some of the G/L's we can see Multiple times for each individual.
    Can any one please explain where does we set up the the revision information for the G/L Accounts .
    Appreciate If anyone can help to know this information.
    Thanks & Regards,
    Sandhya.

    Hi Gopal,
    Counting class are assigned to the Periodic work Schedule 1 to 9 are just arbitart sequence numbers and have no meaning in general they are used for linking Pweriodic Work schedules with differences.
    You can use the class for absence and attendance counting to specify different methods of counting according to the period work schedule.
    They have no other meaning apart from that.
    Thanks and Regards
    Swati

  • Query regarding DB_16k_CACHE_SIZE

    Hi Friends,
    I have got a urgent query regarding db_16k_cache_size parameter.I have created a tablespace with 16k block size,and i have configured the db_16k_cache_sieze to 208M accordingly.I have kept a table in this tablesspace whose presenet size is 323 GB.Some complex queries will be running on this table comprising groups,some complex joins,ordes,analytical functions etc.
    I am having 8 GB of SGA.Now my query is whether i have to increase the db_16k_cache_szie parameter from its present size to get better performance and if it is then how to detemine what will be the optimal size of db_16k_cache_size.
    Please help...
    Thanks
    somy

    Post your query what u have tried. Then only we might be help with you

  • Query regarding Crystal Reports Server

    Hi,
    I am new to Crystal Reports.
    I have created a couple of .rpt files using CR2008 and I am loading these report files in my aspx pages using CrystalReportViewer control.
    I am planning to host my webApp on IIS in production environment. Maximum simultaneous/concurrent connections to my reports would be 1 or 2.
    My question is:
    1. Do I need Crystal Reports Server in this scenario?
    2. In future if the number of concurrent users to report increases then do I need to go for Crystal Reports Server? Will just buying and installing the Crystal reports server on production server work? or will I have to do some configuration or some other changes in the existing deployed reports? OR Will I have to deploy my existing reports on Crystal Report Server again?
    Any help will be highly appreciated.
    Thanks in advance,
    Manish

    Manish, please do not cross post:
    Query regarding Crystal Reports Server
    See the [Rules of Engagement|http://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/rulesofEngagement] for more details.
    Marking this thread as answered and locking...
    - Ludek

  • Query regarding database access segregation using os authentication in windows environment

    Hi ,
    I have a query regarding database access segragation using os authentication (like sqlplus "/ as sysdba") in windows environment.Let me briefly explain my requirement:-
    Suppose you have two DBA`s viz DBA1 and DBA2 and 4 databases resideds in a windows server say A,B,C & D.Now I want to set up such a way if DBA1 logs into the server then he can login to database A and B only using OS authentication and DBA2 can login to database C and D only using OS authentication.
    Please let me know how to do setup for this requirement.
    Database version is 11.2.0.3

    1494629, I am not a Windows person but if there is any way to do this I suspect some additional information is necessary:
    Are the DBA users members of the Administrators Group ?
    Do all 4 database share the same $ORACLE_HOME ?
    I suspect if either answer above is yes then this is not possible, but like I said I am not a Windows person.  I would just ask for two servers and the associated licensing to be acquired.  The requirement to spend money to do something management wants usually elimanates the request in my world.
    HTH -- Mark D Powell --

  • Query regarding using JNI in linux

    Hi
    I have a query regarding JNI.We have a situation in which
    we have some c programmes and we want to call that c programme method in my java code. The problem is that in JNI the native code signature should match the signature of the method of the header file generated by javah. We donot want to change the signature of the native code since it is hard to debug.So please suggest me a way out that i can call the native method without changing the signature of the native code.Please if u could give me some few simple example
    Thanking u

    So please suggest me a way out that i can call the native method without changing the signature of the native code.You write a wrapper. Your java JNI class has methods. Those methods are written in C by you. Those methods are new code. Those methods call your existing C methods.
    Please if u could give me some few simple example.http://java.sun.com/docs/books/tutorial/native1.1/index.html

  • Urgent query regarding performance

    hi
    i have one query regarding performance.iam using interactive reporting and workspace.
    i have all the linsence server,shared services,and Bi services and ui services and oracle9i which has metadata installed in one system(one server).data base which stores relationaldata(DB2) on another system.(i.e 2 systems in total).
    in order to increase performance i made some adjustments
    i installed hyperion BI server services, UI services,license server and shared services server such that all web applications (that used web sphere 5.1) such as shared services and UI services in server1(or computer1).and remaining linsence and bi server services in computer2 and i installed database(db2) on another computer3.(i.e 3 systems in total)
    my query : oracle 9i which has metadata where to install that in ( computer 1 or in computer 2 )
    i want to get best performance.where to install that oracle 9i which has metadata stored in it.
    for any queries please reply mail
    [email protected]
    9930120470

    You should know that executing a query is always slower the first time. Then Oracle can optimise your query and store it temporary for further executions. But passing from 3 minutes to 3 seconds, maybe your original query is really, really slow. Most of the times I only win few milliseconds. If Oracle is able to optimize it to 3 seconds. You must clearly rewrite your query.
    Things you should know to enhance your execution time : try to reduce the number of nested loops, nested loops give your an exponential execution time which is really slow :
    for rec1 in (select a from b) loop
      for  rec2 in (select c from d) loop
      end loop;
    end loop;Anything like that is bad.
    Try to avoid Cartesian products by writing the best where clause possible.
    select a.a,
             b.b
    from  a,
            b
    where b.b > 1This is bad and slow.

  • Query regarding SCN

    Good day gentleman,
    I have a query regarding SCN, how can I know the current status of SCN(in oracle 9i) database , is there any view for that.
    I will also be grateful if some one will tell me on which events Oracle generates a new SCN number.
    With Regards
    Anshuman

    Sir..
    The current system SCN can be queried using dbms_flashback.get_system_change_number.
    The SCN of the last checkpoint can be found in v$database
    Virtually.. each time a modify takes place the scn is increased.
    Acr

  • Query regarding moving components

    I have a JPanel (call it panel1) in another JPanel which has setlayout(null).
    i want to be able to "drag" around panel1 in the other panel.
    i used a quick method of adding a MouseMotionListener to panel1, and under mouseDrag(mouseevent e) had the panel just reset its setLocation to the current getX getY coordinates.
    This method does not work well, with the panel flickering abit, and not following the mouse too well, and even at some points jumping to a random location.
    Whats the best way of achieving this?
    thanks for any help in advance

    Hi,
    Thank you very much for the response. I have a query regarding the same. If i am making changes only in one single report and i am moving it to the quality. Now again i am making changes in the same report and saving it in a different request and moving it to the production. in this case, i wanted to know whether the whole changes made in the first and second request will reflect in the production or only the 2nd request's change will only reflect (since it is only a single report. there is no include in the program)
    Kindly send ur suggestions.
    Best regards,
    John

  • Hi guys can someone help with a query regarding the 'podcast app' why do they not have all the episodes that relate to one show available why only half or a selected amount

    Hi guys can someone help with a query regarding the 'podcast app' why do they not have all the episodes that relate to one show available why only half or a selected amount

    THanks...but some days they have all the episodes right back to the very first show...ive downloaded a few but they are only available every now and then which makes no sense...why not have them available the whole time ??

  • Query regarding regx

    Hi,
    I have a query regarding regular expression.
    what regular expression should I use which matches the following urls
    http://www.abc.com/xyz
    http://www.abc.com/xyz/abc.htm
    http://www.abc.com/xyz/<any thing>
    but it should not match
    http://www.abc.com/xyz45d
    http://www.abc.com/xyz<anything> if(anything does not start with /)
    I wrote the regx as : (http://www.abc.com/xyz)(/\w)*
    but it also matches the last url.
    Thanks
    Edited by: JL.Nayak on Jun 26, 2008 9:36 AM

    prometheuzz wrote:
    kajbj wrote:
    No, that's also incorrect.I have always found it a bit odd that people continue to answer questions that already have been answered, and especially if they post an incorrect answer.Usually this can be explained by the fact that there are still some Dukes to be rewarded to the thread in question. That's not the case with this one: odd indeed.But does that mean that you shouldn't read the other replies before you post your reply?
    (There must be a rule that says that you aren't allowed to read the other replies if you are posting in a certification thread, another odd thing)

Maybe you are looking for

  • JDBC-ODBC bridge

    Hello, I'm using JDK1.5 and have a working connection to MySQL using JDBC. I now need to connect to Interbase database using ODBC and that's where I'm completely lost. Could somebody please tell me if I have to download a JDBC-ODBC bridge or if it's

  • IPhone apps won't update, iTunes Store won't open

    I can't figure out why my apps won't update on my iPhone. I have rebooted, deleted the apps that wouldn't update and froze (waiting) and rebooted after that. I may not have the greatest wifi connection ... I am out of town and dependent on hotel/conv

  • Schedule Receiver RFC communication channel to call R3 RFC-FM.

    Hi, I have requirement that I need to schedule/trigger from PI to RFC call R3 function module. Wonder if anyone here has done similar thing before? I tried to use ATP (Availability time planning) in RWB. But this seem does not success for me as there

  • A/R issue

    hello all , i do have a question in A/R. how to provide ability to autofax statement of accounts.

  • Text Design Question

    I am making t-shirts designs and I am trying to have the font rainbow so it fits on a shirt with a logo underneath...I have looked everywhere to try and figure out how to do tis...does anyone know how? Please help!