Search for record in txt and print to console

QairNo: 21, PostCd: 12, Age: 21, Gender: 2, Q1Res: 1, Q2Res: 2, Q3Res: 3,
QairNo: 23, PostCd: 21, Age: 12, Gender: 2, Q1Res: 1, Q2Res: 2, Q3Res: 3,
QairNo: 32, PostCd: 32, Age: 12, Gender: 1, Q1Res: 2, Q2Res: 1, Q3Res: 2, Hi i manage to write the above entry into database.txt
now i need to search and print the particular data i need. For example i enter *21* and it will print all the attribute that belong to it.
Please forgive me i am new to this, i have google for example but i can`t apply them for some reason. Below are my code, thank you for helping out !
public class PollSummary {
     public static void main (String args[]) throws IOException {
          //int inputQuestionNum= 0;
          String key = "QairNo: ";
          Scanner input = new Scanner(new FileReader("polldata.txt"));
          while(input.hasNextLine()){
               System.out.println(input.nextLine());
          //System.out.println("Enter the Questionnaire Number to view records");
          //inputQuestionNum = Integer.parseInt(entry.nextLine());
           while (input.hasNext() && input.findInLine(key) != null)
                 String fileLine = input.nextLine();
                 System.out.println(fileLine);
     }//end main
}//end class

You should use a map, just use the QuairNo as a key (aside: what is a Quair?)
http://java.sun.com/docs/books/tutorial/collections/interfaces/map.html

Similar Messages

  • Search for records in the event viewer after the last run (not the entire event log), remove duplicate - Output Logon type for a specific OU users

    Hi,
    The following code works perfectly for me and give me a list of users for a specific OU and their respective logon types :-
    $logFile = 'c:\test\test.txt'
    $_myOU = "OU=ABC,dc=contosso,DC=com"
    # LogonType as per technet
    $_logontype = @{
        2 = "Interactive" 
        3 = "Network"
        4 = "Batch"
        5 = "Service"
        7 = "Unlock"
        8 = "NetworkCleartext"
        9 = "NewCredentials"
        10 = "RemoteInteractive"
        11 = "CachedInteractive"
    Get-WinEvent -FilterXml "<QueryList><Query Id=""0"" Path=""Security""><Select Path=""Security"">*[System[(EventID=4624)]]</Select><Suppress Path=""Security"">*[EventData[Data[@Name=""SubjectLogonId""]=""0x0""
    or Data[@Name=""TargetDomainName""]=""NT AUTHORITY"" or Data[@Name=""TargetDomainName""]=""Window Manager""]]</Suppress></Query></QueryList>" -ComputerName
    "XYZ" | ForEach-Object {
        #TargetUserSid
        $_cur_OU = ([ADSI]"LDAP://<SID=$(($_.Properties[4]).Value.Value)>").distinguishedName
        If ( $_cur_OU -like "*$_myOU" ) {
            $_cur_OU
            #LogonType
            $_logontype[ [int] $_.Properties[8].Value ]
    #Time-created
    $_.TimeCreated
        $_.Properties[18].Value
    } >> $logFile
    I am able to pipe the results to a file however, I would like to convert it to CSV/HTML When i try "convertto-HTML"
    function it converts certain values . Also,
    a) I would like to remove duplicate entries when the script runs only for that execution. 
    b) When the script is run, we may be able to search for records after the last run and not search in the same
    records that we have looked into before.
    PLEASE HELP ! 

    If you just want to look for the new events since the last run, I suggest to record the EventRecordID of the last event you parsed and use it as a reference in your filter. For example:
    <QueryList>
      <Query Id="0" Path="Security">
        <Select Path="Security">*[System[(EventID=4624 and
    EventRecordID>46452302)]]</Select>
        <Suppress Path="Security">*[EventData[Data[@Name="SubjectLogonId"]="0x0" or Data[@Name="TargetDomainName"]="NT AUTHORITY" or Data[@Name="TargetDomainName"]="Window Manager"]]</Suppress>
      </Query>
    </QueryList>
    That's this logic that the Server Manager of Windows Serve 2012 is using to save time, CPU and bandwidth. The problem is how to get that number and provide it to your next run. You can store in a file and read it at the beginning. If not found, you
    can go through the all event list.
    Let's say you store it in a simple text file, ref.txt
    1234
    At the beginning just read it.
    Try {
    $_intMyRef = [int] (Get-Content .\ref.txt)
    Catch {
    Write-Host "The reference EventRecordID cannot be found." -ForegroundColor Red
    $_intMyRef = 0
    This is very lazy check. You can do a proper parsing etc... That's a quick dirty way. If I can read
    it and parse it as an integer, I use it. Else, I just set it to 0 meaning I'll collect all info.
    Then include it in your filter. You Get-WinEvent becomes:
    Get-WinEvent -FilterXml "<QueryList><Query Id=""0"" Path=""Security""><Select Path=""Security"">*[System[(EventID=4624 and EventRecordID&gt;$_intMyRef)]]</Select><Suppress Path=""Security"">*[EventData[Data[@Name=""SubjectLogonId""]=""0x0"" or Data[@Name=""TargetDomainName""]=""NT AUTHORITY"" or Data[@Name=""TargetDomainName""]=""Window Manager""]]</Suppress></Query></QueryList>"
    At the end of your script, store the last value you got into your ref.txt file. So you can for example get that info in the loop. Like:
    $Result += $LogonRecord
    $_intLastId = $Event.RecordId
    And at the end:
    Write-Output $_intLastId | Out-File .\ref.txt
    Then next time you run it, it is just scanning the delta. Note that I prefer this versus the date filter in case of the machine wasn't active for long or in case of time sync issue which can sometimes mess up with the date based filters.
    If you want to go for a date filtering, do it at the Get-WinEvent level, not in the Where-Object. If the query is local, it doesn't change much. But in remote system, it does the filter on the remote side therefore you're saving time and resources on your
    side. So for example for the last 30 days, and if you want to use the XMLFilter parameter, you can use:
    <QueryList>
    <Query Id="0" Path="Security">
    <Select Path="Security">*[System[TimeCreated[timediff(@SystemTime) &lt;= 2592000000]]]</Select>
    </Query>
    </QueryList>
    Then you can combine it, etc...
    PS, I used the confusing underscores because I like it ;)
    Note: Posts are provided “AS IS” without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

  • Search for records by Remote Key or Remote System in Data Manager

    Hi all,
    We have a requirement to search for records by Remote key and/or Remote System at the main table level. Is it possible to do this using the Data Manager? If so, how?
    Thanks in advance!
    Lavanya.

    Hi,
    I crosschecked with MDM 5.5 and Don't think it is possible through Data Manager. How ever using APIs you can search records using remote key/ remote system.
    Regards,
    Shiv

  • Search for records in a table on the basis of a function

    Hi,
    How is it possible to use a function as search criteria in a sql query ?
    For example, I have the following query :
    select a.job_name JOB_NAME, substr(a.job_name,instr(a.job_name,'.',-1)+1) as AUTNAME
    FROM autosys.job a
    where a.job_name like %PRD%' and a.command like '%dsjob%'
    and a.command not like 'substr(a.job_name,instr(a.job_name,'.',-1)+1)';
    This is now working because of the use of function "substr" on the right side of the query.
    How can I write the query so as to find the same result as using this function ?
    Can someone help me out on this ?
    Thanks

    Among other things, you have the quotes in the wrong place in the NOT LIKE predicate. As posted, you are searching for records where command does not contain the literal string substr(a.job_name,instr(a.job_name,'.',-1)+1). I don't think that is really what you are after. You need to concatenate the operators to the results of the SUBSTR function. Something more like:
    SELECT a.job_name job_name,
           SUBSTR(a.job_name, INSTR(a.job_name, '.', -1)+1) as autname
    FROM autosys.job a
    WHERE a.job_name LIKE 'HP.TM.%PRD.%' and
          a.command LIKE '%dsjob.sh%' and
          a.command NOT LIKE '%'||SUBSTR(a.job_name, INSTR(a.job_name, '.', -1)+1)||'%'; John

  • Help-ColdFusion - enabling a user to search for records in a database by entering a startand end date - (CREATEODBCDATE)

    I want to enable a user to enter a start and end date to
    define the period they want to search for records of members who
    joined on certain dates. Funny thing is...I've got it to work half
    of the time. For e.g. I have 4 records between 26/10/2005 and
    1/08/2006. When I enter 01/01/2005 as startDate and 31/08/2006 as
    endDate, I get the 4 records. However, if I alter the endDate to
    01/09/2006 I get every record in the database!!!??? Why's this? I
    can't get my head around it!
    Here's my code:
    First the code for the form the user input the search
    criteria on:
    <html>
    <body>
    <FORM action="memberJDateSearch.cfm" method="post">
    <p>Start Date: <input type="text"
    name="startDate">
    <br>End Date: <input type="text" name="endDate">
    <input type="reset" value="Clear">
    <input type="submit" value="Submit">
    </FORM>
    </body>
    </html>
    Simple enough. Now the code for the process and display page:
    <html>
    <body>
    <cfquery name="memberJDateSearch"
    datasource="jpkelle2-access">
    SELECT *
    From members
    WHERE ((joinDate BETWEEN #CreateODBCDate(startDate)# AND
    #CreateODBCDate(endDate)#))
    </cfquery>
    <table border=1 bgcolor="beige" cellpadding="3"
    cellspacing="0">
    <tr>
    <th>Member ID</th>
    <th>Name</th>
    <th>Sex</th>
    <th>Date of Birth</th>
    <th>Address</th>
    <th>Email</th>
    <th>Date Joined</th>
    </tr>
    <CFOUTPUT Query="memberJDateSearch">
    <tr>
    <td><center>#memberID#<center></td>
    <td width="15%">#forename# #initial#
    #surname#</td>
    <td>#sex#</td>
    <td width="10%">#disp('#dob#')#</td>
    <td>#address#, #town#, #county#, #postCode#</td>
    <td>#email#</td>
    <td width="10%">#disp('#joinDate#')#</td>
    </tr>
    </CFOUTPUT>
    </table>
    <hr><p>End of members list.</p>
    </body>
    </html>
    any ideas? please help me.

    Try formatting your dates first (before the CreateODBCDate
    call). I just tried this on my test page and it worked properly. I
    removed the DateFormat calls, keeping the dates in your format and
    it didn't work. See if something like the following will help:
    <cfset startDate =
    DateFormat("31/01/2006","dd/mm/yyyy")/>
    <cfset endDate =
    DateFormat("01/09/2007","dd/mm/yyyy")/>
    <cfquery name="memberJDateSearch"
    datasource="jpkelle2-access">
    SELECT *
    From members
    WHERE ((joinDate BETWEEN #CreateODBCDate(startDate)# AND
    #CreateODBCDate(endDate)#))
    </cfquery>

  • I wish to create a fixture book for a sports team and print it using Duplex. It will consist of 19 pages

    I wish to create a fixture book for a sports team and print it using Duplex. It will consist of 19 pages

    Can't see what you are looking at.
    You will need to describe what exactly you are talking about.
    Meanwhile see Imposing Booklets or Duplex printing:
    http://www.freeforum101.com/iworktipsntrick/viewtopic.php?t=181&highlight=imposi tion&mforum=iworktipsntrick
    Imposed Booklets have pages in multiples of 4, Duplex documents of course in multiples of 2.
    Peter

  • Is it possible to search for strings containing spaces and special characters?

    In our RoboHelp project, there are figures with text labels such as Figure 1, Figure 3-2, etc.
    When I search for "Figure 3" I get all pages containing "Figure" and "3", even if I surround it in quotes.  Similarly, searching for "3-2" treats the '-' character as a space and searches for all pages containing '3' or '2'.
    Is there a way to search for strings containing spaces and special characters?

    In that case I think the answer is no if you are using the standard search engine. However I believe that Zoom Search does allow this type of searching. Check out this link for further information.
    http://www.grainge.org/pages/authoring/zoomsearch/zoomsearch.htm
      The RoboColum(n)
      @robocolumn
      Colum McAndrew

  • Search for mai in gmail and copy text

    I am having hard time to copy text. Basically, I need to search for mail in gmail and copy text to be sent as text message or copy as note.
    1 In ff and default browser, I can search for mail, but no select option
    2 In Nokia messaging there is no option for even search.
    When I swipe from left to right, whole scree is moving. Appreciate any help.

    Check out the Scout, for searches in Contacts/ Conversations, etc....
    /t5/Maemo-Devices/Scout-released-for-N900/td-p/739629
    For Copy-Pasting from Gmail, I am not aware of the technique of doing the same from a browser. The copy-paste function works well from a text-field to another text-field.
    So, I just forward the Gmail message, so that the body of the text appears on a text-filed inside the browser......and then I copy-paste it................without really forwarding the message to anyone

  • So, I am travelling to Italy next week.  I am from the US.  VW's "Trip Planner" suggests my iPhone 5s will not work there.  Then, they suggest (via options below) that I can send Txt for $0.050/txt and Receive for $0.05/txt.  How can I confirm which is tr

    So, I am travelling to Italy next week.  I am from the US.  VW's "Trip Planner" suggests my iPhone 5s will not work there.  Then, they suggest (via options below) that I can send Txt for $0.050/txt and Receive for $0.05/txt.  How can I confirm which is true?

    We are here to help! Where are you traveling to? How long will you be there for? What kind of services are you looking to use?
    KarenC_VZW
    Follow us on Twitter @VZWSupport

  • SharePoint 2010 Enterprise Search for User Profile tags and Notes

    Hi,
    Actually my requirement is, "Sharepoint Enterprise Search for User Profile tags and Notes".
    I would like to use the Tags and Notes in enterprise search.
    Is it possible?
    Thanks & Regards
    Poomani Sankaran

    Check if this helps
    http://blogs.msdn.com/b/spses/archive/2011/02/05/social-computing-part-3-activity-feeds-social-ratings-tags-and-notes.aspx
    If this helped you resolve your issue, please mark it Answered. You can reach me through http://itfreesupport.com/

  • We are using apple tv to try to access our itunes account on the computer.  We see our library of music but when we click on the song it searches for a long time and then says that it cannot access the itunes store.  Any ideas on what we are doing wrong?

    We are using apple tv to try to access our itunes account on the computer.  We see our library of music but when we click on the song it searches for a long time and then says that it cannot access the itunes store.  Any ideas on what we are doing wrong?

    Welcome to the Apple Community.
    Try the following steps, check whether things are working after each step where appropriate, before trying the next.
    Restart the Apple TV (Settings > General > Restart).
    Restart the Apple TV by removing ALL the cables for 30 seconds.
    Restart your router.
    Reset the Apple TV (Settings > General > Reset > Reset all settings)
    Restore the Apple TV (Settings > General > Reset > Restore)

  • Do I need the same ip address for my computer, router and printer?

    Do I need the same IP address for my computer, router and printer?
    I am trying to reset my router. I have had a lot of problems with "no connection" to my wireless printer. I reinstalled the software and it works for a while.
    Also, lose connection a lot on my laptop or it says I am a guest. My cable provider said it is my router.

    A typical convenient-sized "block" of addresses commonly used is just under 256 addresses. The router almost always is at location xx.yy.zz.1
    By default, DHCP will pass out addresses starting at the next address, xx.yy.zz.2 and keep going up toward 254.
    By convention, the Address at the end of the range ( xx.yy.zz.255 in this case) is a "magic" address used for broadcast messages, and must not be assigned to an actual device.
    To talk to each other easily, the Addresses must "match" in the first three octets of their address, and be different in the last octet, as the above examples do.
    When you produce a reference outside that range, such as asking for Apple's web page at:
    http://17.149.160.49
    It is sent to your Router, which acts as your "agent" in dealing with the Internet. The Router hides your computer's local address and uses its own Public address (provided automatically by your ISP) so send out packets on your behalf, and listen for the answering packets coming back.
    When you use a Router that you control, your computer cannot receive unsolicited queries from the Internet at large because the Router's Firewall discards them. Having a Router that you control means you already have the protection of its Firewall, and need not enable the Firewall built-into your Mac.

  • HT5071 Why isn't my newly published book coming up when I search for it by title and by author on iTunes and iBooks?

    Why isn't my newly published book coming up when I search for it by title and by author on iTunes and iBooks?

    Thanks, but it turns out iTunes just needed another 24 hours. Now when I search in iTunes by my name or book title, it comes up!
    Do you happen to know why it doesn't list my name on itunes? It shows the title and then By (blank). Grr.
    bit.ly/1aveWcg

  • My mac is infected with viruses, Safari can not normally search for constantly appear commercials and some unknown site. What to do? antivirus free program that you recommend?

    my mac is infected with viruses, Safari can not normally search for constantly appear commercials and some unknown site. What to do? antivirus free program that you recommend?

    You may have installed the "VSearch" trojan, perhaps under a different name. Remove it as follows.
    Malware is constantly changing to get around the defenses against it. The instructions in this comment are valid as of now, as far as I know. They won't necessarily be valid in the future. Anyone finding this comment a few days or more after it was posted should look for more recent discussions or start a new one.
    Back up all data before proceeding.
    Step 1
    From the Safari menu bar, select
              Safari ▹ Preferences... ▹ Extensions
    Uninstall any extensions you don't know you need, including any that have the word "Spigot," "Trovi," or "Conduit" in the description. If in doubt, uninstall all extensions. Do the equivalent for the Firefox and Chrome browsers, if you use either of those.
    Reset the home page and default search engine in all the browsers, if it was changed.
    Step 2
    Triple-click anywhere in the line below on this page to select it:
    /Library/LaunchAgents/com.vsearch.agent.plist
    Right-click or control-click the line and select
              Services ▹ Reveal in Finder (or just Reveal)
    from the contextual menu.* A folder should open with an item named "com.vsearch.agent.plist" selected. Drag the selected item to the Trash. You may be prompted for your administrator login password.
    Repeat with each of these lines:
    /Library/LaunchDaemons/com.vsearch.daemon.plist
    /Library/LaunchDaemons/com.vsearch.helper.plist
    /Library/LaunchDaemons/Jack.plist
    Restart the computer and empty the Trash. Then delete the following items in the same way:
    /Library/Application Support/VSearch
    /Library/PrivilegedHelperTools/Jack
    /System/Library/Frameworks/VSearch.framework
    ~/Library/Internet Plug-Ins/ConduitNPAPIPlugin.plugin
    Some of these items may be absent, in which case you'll get a message that the file can't be found. Skip that item and go on to the next one.
    This trojan is distributed on illegal websites that traffic in pirated content. If you, or anyone else who uses the computer, visit such sites and follow prompts to install software, you can expect much worse to happen in the future.
    You may be wondering why you didn't get a warning from Gatekeeper about installing software from an unknown developer, as you should have. The reason is that this Internet criminal has a codesigning certificate issued by Apple, which causes Gatekeeper to give the installer a pass. Apple could revoke the certificate, but as of this writing, has not done so, even though it's aware of the problem. This failure of oversight has compromised both Gatekeeper and the Developer ID program. You can't rely on Gatekeeper alone to protect you from harmful software.
    *If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combination  command-C. In the Finder, select
              Go ▹ Go to Folder...
    from the menu bar and paste into the box that opens by pressing command-V. You won't see what you pasted because a line break is included. Press return.

  • [Spotlight] searching on a remote Volume and printing results

    Morning.
    I want to search on /Volumes/Server$ for all files with the extension .tex created after 2008-30-04 and print the results in a list containing the full paths of all items.
    How can I do that?
    TIA and kind regards, Friedrich

    Hi glsmith, I had been playing around with that sort of command (among many other approaches) to get a find by size, and then the files sorted in order by size, since you can no longer do that thing with Spotlight. Anyway, while had done a pipe to sort, and had also fooled around with various approaches to get a text file output, I had not used xargs (because I know nothing about it, except some commands I have copied from here and there use it). So I was curious about your command, and tried this:
    NoobiX:~ francine$ mdfind -0 -onlyin ~ 'kMDItemFSSize > 209715200' | xargs -0 ls -l | sort -n > ~/Desktop/Greatersearch.txt
    Works fine. But I'm curious about the "-0" option. What is it for? Is it to get a decent text formatting scheme?
    Francine
    Francine
    Schwieder

Maybe you are looking for

  • Error while creating a track in CMS

    Hi all, I am trying to create a track in CMS  using J2ee_ administrator.While saving I am getting the below error. SLD (URL http://rhocrmd2:50000) server exception: User credentials are invalid or user is denied access. The same error is coming while

  • How do you sync more than one iphone on one computer

    how do you sync more than one iphone on one computer?

  • How to process Excel through JDBC

    Hi, there! In windows,we could build an ODBC Driver for excel,then how to write the sql statment to query and update the content of the excel through JdbcOdbcDriver? I have create an ODBC DataSource named Register,the excel file is RegisterInfo.xls a

  • Getting an error -unable to get stable set..i cant identify why??

    MERGE INTO aaa_interim ai USING (SELECT * FROM aaa_staging WHERE record_type = 3 or (record_type=2 and terminate_cause_id=1)) asi ON (ai.vendor_record_id = asi.vendor_record_id) ---remove the field for session_id WHEN MATCHED THEN UPDATE SET duration

  • Definition for job ZACU_MC_MATNR_MODEL1 is incomplete. Job cannot be releas

    Hello Friends, When I checking the status in SM37, my job is remain sheduled. It is not getting finished. On selecting job, when I click on spool, I receive a error message. Definition for job ZACU_MC_MATNR_MODEL1 is incomplete. Job cannot be release