Loop through..getProperties --Simple question!

Hello,
I like to use System.getProperties() and display the name and value of each property by loop through all properties (without specify the name for a particular property).
It sounds very simple but I cannot find any example code in Java's online documentation.
Thanks for any help

Try these lines of code:
public class test
    public static void main (String args[])
        java.util.Properties systemProps = System.getProperties();
        String name = "";
        String value = "";
        for (java.util.Enumeration names = systemProps.propertyNames(); names.hasMoreElements() ;) {
            name = (String)names.nextElement();
            value = systemProps.getProperty(name);
            System.out.println("property '"+name+"' has value '"+value+"'");
}

Similar Messages

  • Loop through table (beginner question)

    Hello,
    I been reading and reading but can´t seem to do what I want to do.
    I do a lot of forms in Livecycle but can´t seem to understand even the most easy loop.
    Lets say I have a table with two columns and ten rows. Textfields in column A is called Cell1 and in column B Cell2.
    I want to look through all the rows for this:
    If(Cell1.rawValue !== null)
    Cell2.fontColor = "255,0,0";
    else
    Cell2.fontColor = "0,0,0";
    If anyone can help me with this I would be very happy. Mayvbe I can start to understand this since it seems like I´m missing out on some very handy functions,.
    / Anders
    Sweden

    Thank you so much
    And if I would like to limit the loop I write as follows?
    for (var a=0;a<10;a++){    
      if (Row.item(a).Cell1.rawValue!==null)       
        Row.item(a).Cell2.fontColor = "255,0,0";    
      else          
    Row.item(a).Cell2.fontColor = "0,0,0"; }
    Thanks again.
    / Anders
    Sweden

  • Forms 6i loop through datablock question

    I am writing a piece of code to loop through items with in a datablock to programmatically set the width between each field.
    I created my data block through the wizard, but then manually added some fields. I have them listed in the order I expect them to be navigated, which is the order I expect them to appear on the screen.
    When I am looping through the data block, I was assuming that next_item would go to the next navigable item, and it doesn't.
    For example, I have items received_today, worked_today, total_waiting, total_for_today, total_calls, total_priority.
    When the code loops through the data block, it actually loops in this order: received_today, worked_today, total_callbacks, total_priority, total_waiting, total_for_today.
    I even set the next navigation item property for each item, but that didn't help.
    My questions:
    1. Is there a way to control what order the data block loops through items?
    2. Why does this line get_item_property(get_block_property(block_name, FIRST_ITEM), x_pos); sometimes return null? (in my "proof of concept" form it returns a value, but the form I am modifying does not)
    Following is my code:
    PROCEDURE set_x_y_positions IS
         current_x_position pls_integer;
         current_y_position pls_integer;
      block_name varchar2(30) := 'BLOCK22';
      CurrentItem varchar2(30);
    BEGIN
      go_block(block_name);
      current_x_position := get_item_property(get_block_property(block_name, FIRST_ITEM), x_pos);
      current_y_position := get_item_property(get_block_property(block_name, FIRST_ITEM), y_pos);
          go_block(block_name);
      loop
           BEGIN
                if :system.cursor_item <> (block_name || '.' || get_block_property(block_name, FIRST_ITEM))
                     and get_item_property(:system.current_item, displayed) = 'TRUE' then            
                  SET_ITEM_PROPERTY(:system.current_item, x_pos, current_x_position + 38);
                  current_x_position := get_item_property(:system.current_item, x_pos);
                end if;
                if :system.cursor_item = 'BLOCK22.INTERNATIONAL' THEN--block_name || '.' || get_block_property(block_name, LAST_ITEM) then
                          exit;
                else
                     next_item;
                end if;
           END;
      end loop;
    END;I am using Forms 6i version 6.0.8.26.0
    Thank you!
    Katia

    I do have an exit, and yes it does run well.
         if :system.cursor_item = 'ATS_MON_REPORTING_QUEUES_VW.INTERNATIONAL' THEN--block_name || '.' || get_block_property(block_name, LAST_ITEM) then
                          exit;
                else
                     next_item;
                end if;That redundant go_block is there because I had some output going to a dummy field in another block, so I had to make sure it was navigating back to the block. But yes, in this code example, that go_block is redundant.
    Thank you, adding the
    current_x_position := get_item_property(block_name||'.'|| get_block_property(block_name, FIRST_ITEM), x_pos);
      current_y_position := get_item_property(block_name||'.'|| get_block_property(block_name, FIRST_ITEM), y_pos); worked perfectly.

  • Question on how to loop through a variable amount of objects

    I have a csv file which I am parsing with powershell and it works perfectly. I would like to speed it up. Currently, I call a line that is customized for each groups list of subnets.
    I have about 30 groups.
    Some groups have one subnet, some have 5 subnets.
    I want to set up some sort of loop to parse everything while executing a single Import-CSV. Currently I call Import-CSV once per group. It takes me about 2-4 minutes to parse the entire file depending on the speed of the machine.
    The csv file has about 30,000 rows. I am not concerned about running out of resources. This is as much a learning challenge as a desire to make better powershell scripts.
    Below is a portion of the one liner that would parse the entire csv file looking only for those items that match, and writing them out to that groups specific csv file.
    Example #1
    Import-Csv $HostList |  Where-Object {$_."IP Address" -Match "^192.1.*" -or $_."IP Address" -Match "^192.2.*" -or $_."IP Address" `-Match "^192.3.*"  .....}| do more stuff...
    Example #2
    Import-Csv $HostList |  Where-Object {$_."IP Address" -Match "^192.7.*" ....}| do more stuff...
    The example above is just a snippet from code that works perfectly.
    The problem I am asking for help with is, when I loop through the items I am matching against (subnets), if one group has 3 items to match against, another has 1, another has 7, how do I set up such a loop?
    Am I using some sort of 'while'  $_."IP Address" or...?
    Do I create a big 30,000 array (Does PS even use arrays?)
    I would love to know what this type of looping is called, and what I can read with examples on how to understand approaching this challenge..
    Thank you for any help.
    -= Bruce D. Meyer

    The reason for the parsing (I thought I explained it, must have been too vague) is I have about 30 agencies in a csv file.
    Each agency can be determined by their subnet(s) and domain(s)
    I need to put all lines in the csv relating to each agency in their own separate csv file to distribute to them so I am not sharing agency 'A' info with the other 29 agencies.
    I get the regex comment. Thank you. For some reason I am rather hesitant to use PCRE under windows. I'll see how it works.
    Your comment on "Reloading a large file repeatedly takes more time", is the exact reason why I asked the question. I want to get away from that.
    I appreciate your quick reply, I think your example will work nicely. 
    -= Bruce

  • Simple Question - Email through SAP Server

    Hi, This is Angeline
    I have very simple question, is that posible Eamil Through SAP application server to hotmail / Yahoo account.. without Mail-server...
    In other words, I don't have Mail server and I want send email to my hotmail or yahoo or gmail account through SMTP...
    Please Advised  Thanks you

    You need a SMTP Server in order to send mails... I can't believe that theres a company using SAP that does not have a mail server.
    Regards
    Juan

  • Simple Question Calling methods from Java files through JSP without JVM

    Hi.
    I've got a simple question (forigve my newbieness)...
    If I'm running Tomcat can I exectue a method in a compiled Java file from a JSP page without having the JVM installed on the server?
    Any thoughts or additional comments would be appreciated.
    Many thanks.

    No... but that's because you can't run Tomcat without
    a JVM installed on the server.
    If you are running Tomcat, you are running a JVM for
    the JSP pages to run in, in which case, yes, the JSP
    pages can call the other Java code... as long as it's
    in the classpath.Thanks a lot for the replies.
    So just to check, if I sign up with a hosting company that offers Tomcat then the JVM will be installed on the server and I can call other Java code as long as it's in the classpath?
    I just want to make sure before I sign up with a hosting company =D
    Thanks again!

  • Question about Looping through tables in Adobe Form

    Hello,
    We have an adobe form which is to be filled offline. It consists of a table. Table can have repeating rows and user can add\remove rows as they wish.  The cardinality of the context node where we need to bind this table data is set to 1…n
    We want to know the process to get all the values in the table back into our context node once the form is uploaded. I assume we need to loop through the table, and add elements to the context node.  Can someone please let us know if we’re on the right track, and provide some sample code if possible?
    <b>We can’t figure out a way to loop through a table inside an Adobe form.</b>
    We are using Web Dynpro Java with Adobe Livecycle Designer 7.1
    Your help is much appreciated.
    Thanks,
    Rob.

    Try using...
    for (z = 0; z < 16; z++) {
         this["cb"+z].setStyle("styleName", "cssCBstyle");
    That is the way to target them.  I haven't dealt with setting styles, so I can't answer for that aspect working or not.

  • Questions reg Looping through a Node inside a Currently Selected Node.

    i have the following context structure in my WD application.
    Parent Customer Node  A<Cardinality 1.n & Selection 1.n & Singleton True>
          Child Addresses Node B<Cardinality 1.n & Selection 1.n & Singleton True>
                  Child Attribute B.City
          Child Attribute A.Name
          Child Attribute A.Age
    For the currently selected Parent Customer Element, i want to read the all the addresses this customer has. How to read all the addresses of the customer and loop through it & show it.
    Any inputs are appreciated.

    Hello Saravanan,
    Please use the Singleton Concept.
    Refer the following links.
    http://help.sap.com/saphelp_nwce711core/helpdata/en/47/be673f79c8296fe10000000a42189b/frameset.htm
    http://wiki.sdn.sap.com/wiki/display/WDJava/SupplyFunctionin+Webdynpro
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/60086bd5-9301-2b10-6f97-a14366a5602b/
    if you have doubt in implementation then let us know.
    Regards
    Nizamudeen SM

  • Loop through checkbox in Oracle APEX 4.2 (using JQuery Mobile)

    Hello!
    I want question text and a report containing the possible answers is shown on a page. An answer can be selected by clicking on the checkbox. After hitting the submit button, the selected checkboxes containing the Answer Text, an answer_id and the current session_id are to be inserted into a table within the database.
    Within Oracle APEX 4.2, I am using a classic report to achieve this. Thich is actually a bad solution, because the checkboxes within the report are shown as simple HTML checkboxes, instead of neat JQueryMobile checkboxes). Anyway, this is my current solution:
    Is use this code for creating the classic report:
    SELECT APEX_ITEM.CHECKBOX(1,answer_id), answer_id, answer_text
    FROM ANSWERS
    WHERE question_ID = :P10_Question_ID;
    The insert of the data is done via the on submit process "On Submit - After Computations and Validations"
    This is the code for the on submit process:
    DECLARE var_session_id NUMBER := :P0_SESSION_ID;
    BEGIN
    FOR i in 1..APEX_APPLICATION.G_F01.COUNT LOOP
    INSERT INTO STUDENT_ANSWERS (answer_id, answer_text, session_id)
    SELECT a.answer_id, a.answer_text, var_session_id
    FROM ANSWERS a WHERE a.answer_id = APEX_APPLICATION.G_F01(i)
    END LOOP;
    COMMIT;
    END;
    But this solution does not work. Instead, nothing is inserted into the database.
    I don't know why the process is not inserting into the database, maybe there is something wrong with this line here WHERE a.answer_id = APEX_APPLICATION.G_F01(i) ?
    I even tried a simple update process for testing purposes, but this doesnt work either:
    BEGIN
    FOR i in 1..APEX_APPLICATION.G_F01.COUNT LOOP
    UPDATE STUDENT_ANSWERS SET text = APEX_APPLICATION.G_F03(APEX_APPLICATION.G_F01(i))
    WHERE am_id = APEX_APPLICATION.G_F02(APEX_APPLICATION.G_F01(i));
    END LOOP;
    COMMIT;
    END;
    Can anybody tell me how to loop through a checkbox within ORACLE APEX 4.2 and how to insert the values ANSWER_ID, ANSWER_TEXT and SESSION_ID into the table STUDENT_ANSWERS after hitting the submit button? If you would know how to do it without using a report but a simple checkbox, this would be even more helpful for me!

    I would start by putting this after submit, to check the contents of the array.
    apex_debug.message('count:'||apex_application.g_f01.COUNT);
    FOR i IN 1..apex_application.g_f01.COUNT LOOP
        apex_debug.message('i:'||i||':'||apex_application.g_f01(i));
    END LOOP;
    Then compare the contents with your answers table.

  • Loop Through Rows in SQL Report.

    Hello Everyone,
    I've been creating a very different application, and I've run into quite the roadblock.
    Let me give you a breif about the problem.
    I have a form that needs to be dynamic and thus is created at runtime.
    I have used the APEX_ITEM and a SQL SELECT CASE to create a dynamic report.
    For example if the DATATYPE column in my table says DATE, I create an APEX_ITEM.DATE_POPUP, if it says CHAR i create a textbox, and if a column called
    LOV is populated APEX_ITEM.SELECT_LIST_FROM_QUERY using the number value of the LOV to query a List of Values from another table.
    Now this brings me to say in a single column of the there could be different data_types. meaning the multi-row update functionality with apex will not work.
    Getting the data to display is easy. However saving the updates is a different story.
    Which brings me to my question. Does anybody know of way in which you can loop through each row in a SQL Report on APEX and assess each row individually.
    I'd like to accomplish something like this
    LOOP
    MyUpdateProcedure(currentrow_id,currentrow_datatype, currentrow_value)
    Go to Next Row in Report
    END LOOP;
    Pretty simple in theory? Do we have an APEX expert out there who could give me a hand with this?

    Codes,
    It sounds to me like you could add a hidden field to tell you what you need to know in order to determine the column to update.
    Assuming it was created using the parameter p_idx = 50 and contained the names you provided (eg DATA_DATA) and your primary key is created using p_idx = 1 then you could add the logic for the update into an on submit process something like so
    FOR i IN 1 .. apex_application.g_f01.COUNT
    LOOP
    CASE apex_application.g_f50(i)
    WHEN 'DATA_DATA' THEN
    -- run the update against the data column
    WHEN 'CHAR_DATA' THEN
    -- run the update against the char column
    etc.
    If the multi-type column is created with the apex_item api using p_idx = 2 then you just refer to it in the loop as apex_application.g_f02(i) and the primary key is apex_application.g_f01(i).
    I hope this helps.
    Greg

  • Fastest way to loop through a group of strings

    I am trying to optimize a small class that loops through an array of strings and compares to see if another string equals one of the values, for example:
    String test = "this is test5";
    String array[] = {"test1","test2","test3, test4,test5,test6,test7,test8"};
    for(int i = 0;i < array.length; i++)
    if (test.endsWith(array))
    return array[i];
    }The array that I am using holds closer to 15 values, but this loop can be hit thousands of times a day.  My  question is, are there any faster ways to loop through multiple strings than using arrays?  How do array lists or maps compare?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    sarcasteak wrote:
    The array that I am using holds closer to 15 values, but this loop can be hit thousands of times a day. 15,000 comparisons a day is nothing. The following code does 15 million String compares in 188 ms.
    public class StrCmp {
      public static void main(String... args) {
        String[] arr = {"abc", "sdfasdlfkjasldfjalsdkfj", "234l2kjala34kh", "slkfjal3490u saf",
                        "234lkjasldfhk23k4jhasf", "23l4kjsf", "alsflsdjkf", "aslkdfajsdf3h", "zzzzz",
                        "uhuhuhuhuh", "uhu2huh234234", "n234aoiuf", "234lasdhvoaih3", "zoziucvoiu", "asdflsjfl"};
        long start = System.currentTimeMillis ();
        for (int i = 0; i < 1000000; i++) {
          String str = "qqq";
          for (String str2 : arr) {
            if (str2.endsWith (str)) {
              System.out.println ("match");
        long end = System.currentTimeMillis ();
        System.out.println((end - start) + " millis");
    My question is, are there any faster ways to loop through multiple strings than using arrays? How do array lists or maps compare?Before you worry about taking something simple that works and complicating it to make it faster, make sure there's a reason to do so.
    If you do in fact need to make it faster, there are several different things you could do, but which one is best depends on a number of factors specific to your particular requirements and use cases.

  • Simplest way to loop through a HashMap?

    Hi everyone,
    I'm a beginner at JSP, so please excuse my ignorance...
    I have a HashMap in which I need to loop through and print every "key" and associated "value".
    Doing research, I have come across multiple examples, but they all seem (to me) rather complex for something I think should be simple.
    Here is some code I have now. C_TITLE is a HashMap. My question is, is there an easier way to do this where I don't have to invoke a subclass? Or is this as simple and easy as it can get?
    Thanks!
    if (C_TITLE.size() > 0) { //only loop if there are items in this hashmap
         for (Iterator i=C_TITLE.entrySet().iterator(); i.hasNext(); ) {
                  Map.Entry mapentry = (Map.Entry) i.next();
              out.print (mapentry.getKey() + "|");
              out.print (mapentry.getValue() + "<BR>\n");
    }

      Iteratir iter = C_TITLE.keySet().iterator();
      while(iter.hasNext()) //or your for as well
          Object key = iter.next();
           Object value = C_TITLE.get(key);
      }With J2SDK 1.5 there is new for loop to iterate through collections.
    This will make Iterators almost unusable.

  • Text is not being displayed in sync on a label when looping through a list -- how to fix?

    I have a list of states (50 states).  I loop through this list (in a winform app -- VS2012) and want to display the current state ID that is being processed in the loop in the text property of a label.  I precede the label.Text = StateID line with
    Application.DoEvents() but I am also (in Debug mode) writing the same text to the console.  The console displays correctly, but there appears to be a lag in the label.Text property
    List<string> StateList = new List<string> { "al", "ak", "az","ar","ca","co","ct","de","fl","ga",...};
    foreach (string stateID in StateList)
        Application.DoEvents();
        lblStateID.Text = "State is " + stateID;  //--there is a lag here
    I vaguely recollect something about a NotifyPropertyChanged event.  I know this is common in WPF, but is there something similar in winform?  Or is there a way to make the desired text to be displayed in the label.Text property in synchronization
    with the loop?
    Rich P

    Thank you.  This is way simpler than implementing the INotifyPropertyChanged Interface.  Although, here is an article on the INotifyPropertyChanged Interface and event
    http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged(v=vs.110).aspx
    Rich P

  • Automator - Loop through a text file and process data through a 3rd party software

    Just stumbled on Automator the other day (I am a mac n00b) and would like to automate the processing of a text file, line-by-line, using a third party tool.  I would like Automator to loop through the text file one line at a time, copy the string and keep as a variable.  Next, place the variable data (copied string) into the text field of the 3rd party software for processing.  Once the processing is complete, I would like Automator to fetch the next line/string for processing.  I see items like "copy from clipboard" and  "variables" within the menu but I am not finding much documentation on how to utilizle this tool.  Just hear how potentially powerful it is. 
    The 3rd party software is not a brand name, just something made for me to process text.  I may have to use mouse clicks or tabs + [return] to navigate with Automator.  A term I heard on Bn Walldie's itunes video series was "scriptable software" for which I don't think this 3rd party app would be. 
    Kind regards,
    jw

    Good news and bad news...
    The good news is that it should be entirely possible to automate your workflow.
    The bad news is that it will be a nightmare to implement via Automator, if it's even possible.
    Automator is, essentially a pretty interface on top of AppleScript/Apple Events, and with the pretty interface comes a certain stranglehold on features. Knowing how to boil rice might make you a cook, but understanding flavor profiles and ingredient combinations can make you a chef, and it's the same with AppleScript and Automator. Automator's good at getting you from points A to B but if there are any bumps in the road (e.g. the application you're using isn't scriptable) then it falls apart.
    What I'm getting at is that your requirements are pretty simple to implement in AppleScript because you can get 'under the hood' and do exactly what you want, as opposed to Automator's restricted interface.
    The tricky part is that if no one else can see this app it's going to be hard to tell you what to do.
    I can give you the basics on reading a file and iterating through the lines of text in it, and I can show you how to 'type' text in any given application, but it may be up to you to put the pieces together.
    Here's one way of reading a file and working through each line of text:
    -- ask the user for a file:
    set theFile to (choose file)
    -- read the file contents:
    set theFileContents to (read file theFile)
    -- break out the lines/paragraphs of text:
    set theLines to paragraphs of theFileContents
    -- now iterate through those lines, one by one:
    repeat with eachLine in theLines
      -- code to perform for eachLine goes here
    end repeat
    Once you have a line of text (eachLine in the above example) you can 'type' that into another application via something like:
    tell application "AppName" to activate
    tell application "System Events"
              tell process "AppName"
      keystroke eachLine
              end tell
    end tell
    Here the AppleScript is activating the application and using System Events to emulate typing the contents of the eachLine variable into the process. Put this inside your repeat loop and you're almost there.

  • A simple question on random number generation?

    Hi,
    This is a rather simple question and shows my newbieness quite blatantly!
    I'm trying to generate a random number in a part of a test I have.
    So, I have a little method which looks like this:
    public int getRandomNumber(int number){
            Random random = new Random(number);
            return random.nextInt(number);
        }And in my code I do int random = getRandomNumber(blah)...where blah is always the same number.
    My problem is it always returns the same number. What am I missing here. I was under the impression that nextint(int n) was supposed to generate the number randomly!! Obviously I'm doing something wrong or not using the correct thing. Someone please point out my stupidity and point me in the right direction? Ta

    I think the idea is that Random will generate the same pseudo-random sequence over and over if you don't supply a seed value. (The better to debug with, my dear.) When you're ready to put an app into production, the seed value should be the current system time in milliseconds to guarantee a new sequence with each run.
    Do indeed move Random outside the loop. Think of it like a number factory - instantiate it once and let it pump out the random values for you as needed.

Maybe you are looking for

  • MacbookPro Mavericks OS external monitor - How?

    I have MacbookPro unibody running Mavericks OS, I want to use my LG 32LE5900 TV as an external monitor - How? I've tried HDMI direct from one to the other and bought a Mini Display port to HDMI too, but nothing works. Do you have to change the mac re

  • OSB 11g - send cookes during HTTP redirects

    Hi everybody, I created the OSB business service BS1 to emulate HTTP POST request for the specific URL. The POST request to this URL returns: HTTP/1.1 302 Moved Temporarily Date: Tue, 03 Aug 2010 07:01:21 GMT Server: Apache P3P: CP="NOI DSP COR CURa

  • Cisco ASA to CX upgrade

    Hello, I have a couple of questions. I am upgrading from ASA to ASA CX. This is an existing firewall with configurations, policies, nat rules, etc. 1. When you upgrade to CX, does the firewall keep the configuration: ip address of interfaces, securit

  • Web Dynpro Explorer disappeared!

    I am trying to create my first interactive form. I created the project, the views and the UI elements using the Web Dynpro Perspective in the Developer Studio.  I then tried to create the form.  The Adobe Designer opened OK, but the hierarchy and dat

  • Editing Polaroid Image Viewer

    So, not sure if this is the right section to put this in, so if not I'm sorry! Anyways, I'm currently making a polaroid image viewer working off of this tutorial: http://active.tutsplus.com/tutorials/design/create-a-nifty-polaroid-photo-viewer-with-f