How to cut string from output

I have a program which will pullout the software list of a machine but in output it will display full path with software list buti need only softwarelist how to get it please help me
try{
          String cmd = "reg query \"HKEY_LOCAL_MACHINE\\SOFTWARE\"";
               //\Microsoft"+"\\Windows\\CurrentVersion\\Uninstall\"";
// This one will show you software categories installed
//String cmd = "reg query \"HKEY_LOCAL_MACHINE\\Software\"";
Process p = Runtime.getRuntime().exec(cmd);
Thread.sleep(200l); //terrible, the right way is p.waitFor
//p.waitFor(); /* this command sometimes hangs on windows !!!???*/
InputStream in = p.getInputStream();
byte[] bytes = new byte[16384];
StringBuffer buf = new StringBuffer();
while(true) {
int num = in.read(bytes);
if(num == -1) break;
buf.append(new String(bytes,0,num,"UTF-8"));
System.out.println(buf.toString());
output is:
HKEY_LOCAL_MACHINE\SOFTWARE
(Default) REG_SZ
HKEY_LOCAL_MACHINE\SOFTWARE\Adobe
HKEY_LOCAL_MACHINE\SOFTWARE\ahead
HKEY_LOCAL_MACHINE\SOFTWARE\Alps
HKEY_LOCAL_MACHINE\SOFTWARE\AMD
HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation
HKEY_LOCAL_MACHINE\SOFTWARE\ATI
HKEY_LOCAL_MACHINE\SOFTWARE\ATI Technologies
HKEY_LOCAL_MACHINE\SOFTWARE\Audible
HKEY_LOCAL_MACHINE\SOFTWARE\AVG
HKEY_LOCAL_MACHINE\SOFTWARE\AVG Security Toolbar
HKEY_LOCAL_MACHINE\SOFTWARE\Azur

The string class has a replaceAll method: http://download.oracle.com/javase/6/docs/api/java/lang/String.html#replaceAll%28java.lang.String,%20java.lang.String%29
Juts replace "HKEY_LOCAL_MACHINE\SOFTWARE\" with "" (empty string).
Timo

Similar Messages

  • How to get string from jtextpane along with its attributes

    sir,
    How to get string from jtextpane along with its attributes
    i,e font,size,style,color etc.
    please help me out.
    my mail id is [email protected]

    JTextPane extends JTextComponent
    JTextComponent.getDocument()
    a Document is a set of Element, see Document.getRootElements(). Each Element has attributes, stored within an AttributSet object see Element.getAttributes()
    a Document can also be rendered as a String, see Document.getText( offest, length ), use it with 0 and Document.getLength() as parameters.

  • How to retreive String from the Connection object

    hi all,
    I am using HttpConnection to Connect to the server.I want to retreive string from the Connection.
    As like Connection.openInputStream() is there any method to get the String from the connection.In the server side also i want to send the String not the stream .
    Thanks in advance
    lakshman

    Just read the string from the stream.

  • How to downlaod adobe from output  to presentation server without display

    Hi Experts,
    How to download the adobe form output without displaying the output on the screen. Do we have some concept of OTF data in adobe forms ??? I checked the all the function modules which starts from FP*, but could not find it. Please let me know how to download the output of the form without displaying the output.
    Thanks in advance.
    Jack

    hi,
    when you get data in binary format, append it to the following internal table of type TLINE and then use following code to modify ur binary adta. tehn you can try to convert it into PDF format.
    inernal table declaration:
    * Binary store for PDF
    DATA: BEGIN OF it_pdf_output OCCURS 0.
            INCLUDE STRUCTURE tline.
    DATA: END OF it_pdf_output.
    data : gd_buffer TYPE string,
             it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE.
    code to modify binary data obtained :
    * Transfer the 132-long strings to 255-long strings
      LOOP AT it_pdf_output.
        TRANSLATE it_pdf_output USING ' ~'.
        CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
      ENDLOOP.
      TRANSLATE gd_buffer USING '~ '.
    * Prepare PDF attachment table : it_mess_att
      DO.
        it_mess_att = gd_buffer.
        APPEND it_mess_att.
        SHIFT gd_buffer LEFT BY 255 PLACES.
        IF gd_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
    regards,

  • How to delete string from an array

    I just want to know that what changes i can do to delete the string if contains any extra characters like digits and punctuation marks in the middle or begining of the string but not at the end of the string, i've already tried to delete only the punctuation marks at the end of the string and keep that word. Please dont forget that i m a beginer
    import java.io.*;
    import java.util.*;
    class Project
    public static void main()throws IOException
    // set up input stream
    File finput = new File("C:\\f1.txt");
    FileReader fr = new FileReader(finput);
    BufferedReader fin = new BufferedReader (fr);
    // set up output stream
    File foutput = new File("C:\\f3.txt");
    FileWriter fw = new FileWriter (foutput);
    PrintWriter fout = new PrintWriter (fw);
    String nextLine; // a line read from the file
    StringTokenizer t; // the words within the line
    ArrayList words = new ArrayList(); // an array of words
    //String n = {0,1,2,3,4,5,6,7,8,9};
    System.out.println("Reading file.\n");
    // start
    while (true)
    nextLine =fin.readLine(); // read from input file
    if (nextLine==null) break; // if no more lines, get out
    t = new StringTokenizer(nextLine); // identify words
    while (t.hasMoreTokens())
    String str = (String)t.nextToken();
    str = str.toLowerCase(); // Converting all uppercase to lowercase.
    // Replacing all punctuation marks.
    str=str.replace(',',' ');
    str=str.replace('?',' ');
    str=str.replace('!',' ');
    str=str.replace('.',' ');
    str=str.replace(':',' ');
    str=str.replace(';',' ');
    str=str.replace('"',' ');
    str=str.replace('"',' ');
    str=str.trim(); // Removing empty spaces after words
    words.add(str); // add them to array
    String z; // Declaring string z for sorting.
    for (int i=0; i<words.size(); i++)
    for (int j=i+1; j<words.size(); j++)
    // Sorting the Array list.
    if (((String)words.get(j)).compareTo((String)words.get(i))<0)
    z=(String)words.get(i);
    words.remove(i);
    words.add(i,(String)words.get(j-1));
    words.remove(j);
    words.add(j,z);
    // To replacing word which have got "'".
    if ((String)words.get(i)).indexOf("'")!=-1)
    a="";
    int count[]=new int[words.size()]; //Creating int array for counting the repetition.
    for (int i=0;i<=words.size()-1;i++)
    for (int j=i+1;j<=words.size()-1;j++)
    //Counting the repetition of the string.
    //if (((String)words.get(j)).compareTo((String)words.get(i))==0)
    if (((String)words.get(j)).equals((String)words.get(i))==true)
    count[i]++;
    words.remove(j);
    j=j-1;
    System.out.println("Dictionary\t|\tRepetition");
    System.out.println("==========\t \t==========\n");
    for (int i=0; i<words.size(); i++)
    count[i]++; // initialinzing the value with 1
    // Printing result on the output file.
    fout.println((String)words.get(i));
    // Printing result on the screen with histogram.
    System.out.println((String)words.get(i)+ "\t\t|\t" +count[i]);
    fout.close();
    System.out.println();
    System.out.println("Finished");
    } //end of main.

    The code that you pasted does not seem like written by a beginner. So, did you write the code?
    If so, you should have no problem solving this simple thing.
    If not, then copy and pasting a block of program that you don't understand will keep you as a beginner all the time, so can't help you if you are willing to stay at beginner.
    --lichu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to remove xmls from output?

    Hello All,
    I have created a BPEL process that takes a flat file and converts to an XML file. I get an output of the following (see below). Is there a way that I can remove xmlns="" from the output?
    Incorrect Output
    <?xml version="1.0" encoding="UTF-8" ?>
    <WhseShipNotice xmlns="">
    Correct Output
    <?xml version="1.0" encoding="UTF-8" ?>
    <WhseShipNotice>
    Any suggestions?
    Regards,
    Kathy

    I can remember if this xsd removes namespaces correctly, I think it may still have the initial xmlns at the top but give it a try. Typically what needs to be done is some embedded java to do this.
    <schema targetNamespace="http://www.oracle.com/Gateway"
            xmlns="http://www.w3.org/2001/XMLSchema">
      <element name="Message">
      <complexType>
        <sequence>     
          <element name="Header">
            <complexType>
            <sequence>
               <element name="UniqueID"             type="string"/>
               <element name="RoutingRule"          type="string"/>
               <element name="FileName"             type="string"/>
               <element name="Destination"          type="string"/>
               <element name="TransportType"        type="string"/>
               <element name="Attachment"           type="string"/>
               <element name="MQMessageID"          type="string"/>
               <element name="MQCorrelationID"      type="string"/>
            </sequence>
            </complexType>
            </element>
          <element name="Payload"            type="base64Binary"/>
        </sequence>
      </complexType>
      </element>
    </schema>cheers
    James

  • How to pass string from a class to another on button click

    Hai forum i'm developing an application in which i have frame1(seperate class without main) where i get a excel files and get the tablenames of it(sheets).
    There i choose a sheet from availabe sheets and i have to pass it frame2 on clicking a button on frame1.
    The sheet name is chosen from a JComboBox in frame1:(code)
    sheetcombo.addActionListener(new java.awt.event.ActionListener()     
                        public void actionPerformed(java.awt.event.ActionEvent e)
                                  JComboBox cb = (JComboBox)e.getSource();
                                  String sheetname = (String)cb.getSelectedItem();
    I dont get how to pass this String sheetname to frame2 where i call the constructor of frame1 initialize it. Help me out. Thanks in advance...

    1 write a set method in frame 2 class
    2 create a instance of frame 2 class in frame 1
    3 in actionaPerformed method write code as follows
    frame2obj.set(sheetname)
    this should work :-)

  • How to Read string from keyboard input??

    Hi,
    I am writing an application that requires the user to input string
    text. I have declared a variable String[] SData. The user will enter
    several words in a line of string, and I want to be able to split
    these and assign it to different variables, e.g. A= SData[1]
    My problem is how do you assign the SData to what is being inputted?
    I was using SData = System.in.read()
    But I got a type compatibility error.
    Is there another way I can get user input into a string?
    Does anyone have any ideas? Any help would be greatly appreciated.
    Thank you.

    Is there another way I can get user input into a
    string?
    KeyboardInput
    Adapted from Jacquie Barker's "Beginning Java Objects" (2002)
    pp. 324 - 325
    To use, in main():
    KeyboardInput k = new KeyboardInput();
    k.readLine();
    To get the input stored in k,
    k.getKeyboardInput();
    import java.io.*;
    class KeyboardInput
    //User input is saved in this string
    private static String keyboardInput;
    public String readLine()
    char in;
    // Clears previous input
    keyboardInput = "";
    try
    // Read one integer and cast it into a character.
    // Keeps going until a newline character is read.
    do
    in = (char) System.in.read();
    keyboardInput = keyboardInput + in;
    } while ( in != '\n' );
    catch (IOException e)
    // Reset the input
    keyboardInput = "";
    System.out.print("\n\nError in reading keyboardInput: \n" +
    e + "\n\n");
    // Strips off any leading and/or trailing whitespace
    keyboardInput = keyboardInput.trim();
    // Return the complete String;
    return keyboardInput;
    } // End String readLine()
    public String getKeyboardInput()
    return keyboardInput;
    } // End String getKeyboardInput()
    } // End class KeyboardInput

  • How to get string from a stringBuider reference

    Please see attached image.
    How do I take the values from stringbuilder reference,into LabVIEW string?
    (The DLL is C# and is proven)
    Pls. help.
    Attachments:
    HowToMap_LV_String2StringBuilderReference.zip ‏43 KB

    Just connect the response element to an Invoke Node and select the ToString() method for the StringBuilder class.

  • How to return string from Applet back to the broser textbox

    Hi everybody , i m new to java applet .
    I have an applet running on the browser along with a text box. the applet connects to the database and in the end a string should be copied back to the textbox on the browser. I have no idea how do i do it
    if anybody can help me.
    my applet is working well. its just integration with the browser giving me hard time.
    thanks alll in advance
    reuben

    With "text box", do you mean a text field on a HTML page? If yes, you could use the JSObject class from netscape to issue a Javascript call to the page similar to window.document.form[0].textfieldname and provide the string. The Applet tag must contain the MAYSCRIPT=true argument to allow the Applet to issue Javascript commands.
    Frankl

  • How to cut text from my ipad2

    How do I cut previous emails out of the present one that I'm forwarding.?????

    Press on the info you want to delete to select it. Move the box to get everything you don't want and then select cut.

  • How separate a string from others

    Hi all,
    I'm writing a program need to choose a specific string out of input strings
    An the specific string's diference from others is it begin with a number
    So is there a possible way to do it
    thx....

    String has a method charAt() which you can use to get a character from the String (use charAt(0) for the first character).
    Character has a method isDigit() that returns true or false.

  • How To Cut & Paste From Second Video?

    I have two videos.  They're almost identical except for one scene.
    I've been trying to copy that scene from the first video and paste it into the second.  It would replace the scene in there now exactly.  Both are the same length.
    I haven't had any success.  Is this possible with iMovie?
    Thanks.

    If the relevant scene is also still in an Event, you can drag it from that Event to the project. When you drop it onto the scene to be replaced, a pop-up menu will appear - choose Replace.
    If you can't access the particular scene in an Event, then export the first video and re-import it to an Event. Then select the required scene (drag across the clip to highlight the segment with a yellow border) and drag it to the other project as described above.
    To export the project and retain full quality, follow the steps I outlined in this discussion topic:
    https://discussions.apple.com/thread/3760673?tstart=0
    John

  • How to get substring from string starting from the end of string

    Hi
    How to cut from string:
    $A=C:\ClusterStorage\Volume1\WXP-plwropc300\Virtual Hard Disks\WXP-PLWROPC300_EE20E00F-315E-4781-A6DE-68497D4189B8.avhdx
    this substring (name of VHD file): WXP-PLWROPC300_EE20E00F-315E-4781-A6DE-68497D4189B8.avhdx
    This script should be universal so the best way to be cut all leters from the end of string $A till get the first mark \
    Thank you for help.
    Tomasz
    Kind Regards Tomasz

    PS > Split-Path 'C:\ClusterStorage\Volume1\WXP-plwropc300\Virtual Hard Disks\WXP-PLWROPC300_EE20E00F-315E-4781
    -A6DE-68497D4189B8.avhdx' -leaf
    WXP-PLWROPC300_EE20E00F-315E-4781-A6DE-68497D4189B8.avhdx
    PS >
    That is what "Split-Path" is for:
    ¯\_(ツ)_/¯

  • Output strings from loop into one string

    im trying my best to explain my problem so ber in mind:)
    hey having a bit of trouble with outputing strings from loop
    example
    i typed ab into the textbox
    the output should be 12
    but since it is in a loop it would only output the last string and in this case is 2
    im trying to get both strings from the loop and output strings from loop into one string.
    here is some of my code to understand my problem
    // characters a to f
         char[] charword = {'a','b','c','d','e','f'};
         String charchange ;
      // get text from password textbox
                          stringpassword = passwordTextbox.getText();
                          try {
                          // loop to show password length
                          for ( int i = 0; i < stringpassword.length(); i++ ){
                          // loop to go through alfabet     
                          for (int it = 0; it < charword.length; it++){
                             // if char equals stringwords
                               if (stringpassword.charAt(i) == charword[it]){
                                    System.out.print("it worked");
                                    // change characters start with a
                                    if (charword[it] == 'a'){
                                         charchange = "1";
                                    // change to 2
                                    if (charword[it] == 'b'){
                                         charchange = "2";
                                        }

    Not sure how you are displaying the result but you could display each value as soon as you find it.
    if (charword[it] == 'a'){
        System.out.print("1");
    }If it is in a text field then use append. Or if you really need a String with the entire result then use concatenation.
    if (charword[it] == 'a'){
        charchange += "1";
    }

Maybe you are looking for

  • Blank screen after update (KMS related?)

    After the last kernel update I got a blank screen at boot. I'm not sure, but I think it happens when KMS kicks in. I think it's related to a broken EDID I've been fighting for months. The stop-gap measure I'd been using so far is to have a custom con

  • Getting a "driver error" message when syncing

    The trouble started when my iPod keep getting hung up on a few songs, or would only play half a song, or skip over a bunch of songs. They guy at the apple store said I should wipe it and install the latest iPod software - which is did. At the same ti

  • Address book - multiple emails - send to all

    I have a contact who has requested that when I send her email that I use both of the email addresses in her address book entry. I know how to pick which one to use, but apparently there is not a way to use both of them. I have circumvented the proble

  • I need a replacement hard drive for my iPod Classic 80GB ...  where???????

    I have accidently damaged the hard drive in 80GB Classic iPod. I need a replacement drive , where can i get that from. There is a slight dint at the back of the unit, right where the hard drive sits, because of this Apple Warranty is not valid.

  • TC / Report for Invoice+Packing+Billing  against Sales order

    Dear all, I want to know the std. SAP TC/Report to get Invoice no/Header text/Outbound deleivery against particular Sales order/Customer.