Problem in retriving string

Hi all,
i'm finding problem in retriving string
i'm getting only first line as output
the coding is
import java.io.*;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
class newprg2
public static void main(String args[]) throws IOException
InputStream in = new FileInputStream("e:/rag.txt");
//OutputStream out = newFileOutputStream("e:/rag1.txt");
int c,pos,pos1;
String s=new String();
StringBuffer sb = new StringBuffer();
while((c=in.read())!=-1)
sb.insert(0,(char)c);
sb = sb.reverse();
s = sb.toString();
pos = s.indexOf("verify scan_test",0);
s=s.substring(pos+1);
while(pos>=0)
pos=s.indexOf("_cpdp_=",pos);
pos=s.indexOf("=",pos);
pos1=s.indexOf(';', pos);
s=s.substring(pos+1,pos1);
System.out.println(s);
}here's the input file
verify scan_test  {
  Abb {* verify:0  Value:0  lifecycle:0 *}
  W tset_tp;
  S {  _cpdp_=YYYY10YYYYYYYYYYYYYYYYYYY;
  Abb {* Begin loop test *}
  S {  _cpdp_=YYYY10YYYYYYYYYYYYYYYYYYY;
  S {  _cpdp_=YYYY110YY1YYYYYYYYYYYYYYY;
  S {  _cpdp_=YYYY110YY1YYYYYYYYYYYYYYY;
  S {  _cpdp_=YYYY111YY1YYYYYYYYYYYYYYY;
  }now i'm getting output as
YYYY10YYYYYYYYYYYYYYYYYYY
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
        at java.lang.String.substring(Unknown Source)
        at newprg2.main(newprg2.java:42)but i want output as
YYYY10YYYYYYYYYYYYYYYYYYY
YYYY10YYYYYYYYYYYYYYYYYYY
YYYY110YY1YYYYYYYYYYYYYYY
YYYY110YY1YYYYYYYYYYYYYYY
YYYY111YY1YYYYYYYYYYYYYYY

Manivel wrote:
raghavan,
Alter the code inside the while loop like below, you will get as what you expected.
while (pos >= 0) {
s = s.substring(pos + 1);
pos = s.indexOf("_cpdp_=", pos);
pos = s.indexOf("=", pos);
pos1 = s.indexOf(';', pos);
String ss = s.substring(pos + 1, pos1);
System.out.println(ss);
}-ManiI'm sorry, but, if you are simply going to spew out the answer to someones homework, you could at least explain what was wrong (before the code). They don't care in the least, but having read it, they may retain at least some spark of the meaning that the lesson was intended to teach. Like this it's just cut and paste, and who gives a damn. They learn a lot that way, NOT!

Similar Messages

  • Problem with retriving string from mysql DB

    hi,
    i am storing kannada (india) string into mysql database, that column is
    utf8_general_ci . when saw in db it showing ??????.
    while retriving it also printing ?????.
    what do with this problme, please help to solve this problem..
    thanks
    daya

    hi,
    i am storing kannada (india) string into mysql
    database, that column is
    utf8_general_ci . when saw in db it showing ??????.
    while retriving it also printing ?????.
    what do with this problme, please help to solve this
    problem..
    thanks
    daya
    hi,
    i am storing kannada (india) string into mysql
    database, that column is
    utf8_general_ci . when saw in db it showing ??????.
    while retriving it also printing ?????.
    what do with this problme, please help to solve this
    problem..
    thanks
    dayayou should store the text (kannada-writing) not within a normal CHAR or VARCHAR field in the MySQL-Database. instead store it in a BLOB-field and then retrieve the String by String out=new String (rs.getBytes()); (the BLOB field is used like a Stream so make the appropriate preparations and it should work!
    if not you can alter the above new String to new String(rs.getBytes(),"string-format"); where string-format is the iso-name for your language for instance for western europe "ISO-8859-1"

  • Problem in retriving workitem id from uwl in abap webdynpro

    Hello,
    Curently, I've a problem similar with this post : Problem in retriving workitem id from uwl in abap webdynpro
    But unfortunatelly there is no answer :/
    I've followed this tutorial : http://wiki.sdn.sap.com/wiki/display/WDABAP/IntegratingWebDynproABAPapplicationswithUWLforworkflowin+Portal
    And I have a problem in my WD Abap. The WI_ID field is empty (initial).
    Here is my XML :
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE UWLConfiguration PUBLIC '-//SAP//UWL1.0//EN' 'uwl_configuration.dtd'
      >
    <UWLConfiguration version="1.0">
         <ItemTypes>
              <ItemType name="uwl.task.webflow.TS90000087.ED1CLNT100" connector="WebFlowConnector" defaultView="DefaultView" defaultAction="launchWebDynPro" executionMode="default">
                <ItemTypeCriteria systemId="ED1CLNT100" externalType="TS90000087" connector="WebFlowConnector"/>
                <Actions>
                   <Action name="launchWebDynPro" groupAction="" handler="SAPWebDynproABAPLauncher" returnToDetailViewAllowed="yes" launchInNewWindow="yes" launchNewWindowFeatures="resizable=yes,scrollbars=yes,status=yes,toolbar=no,menubar=no,location=no,directories=no">
                     <Properties>
                        <Property name="WebDynproApplication" value="zps_pnpi"/>
                        <Property name="newWindowFeatures" value="resizable=yes,scrollbars=yes,status=yes,toolbar=no,menubar=no,location=no,directories=no"/>
                        <Property name="DynamicParameter" value="WI_ID1=${item.externalId}"/>
                        <Property name="openInNewWindow" value="yes"/>
                        <Property name="WebDynproNamespace" value="sap"/>
                        <Property name="System" value="ED1CLNT100"/>
                        <Property name="display_order_priority" value="5"/>
                     </Properties>
                     <Descriptions default=""/>
                   </Action>
                </Actions>
              </ItemType>
         </ItemTypes>
    </UWLConfiguration>
    Here are the parameter defined in my application :
    WI_ID     000000000000     SWW_WIID
    WI_ID1     ${item.externalId}     STRING
    And, i've made the test with both the WI_ID and the WI_ID1 in the XML but everytime, no value at all.
    Could you please help me ? It's been three days I'm looking for a solution to get my Workitem ID in my Webdynpro ...

    In fact, it's quite strange, I added the menu and toolbar display and I can see that my url contains the data ...
    http://<begin_of_the_url>DynamicParameter=System%3DED1CLNT100%26wi_id%3D000000629442%26WI_ID%3D000000629442%26WI_ID1%3D000000629442<end_of_the_url>
    So ... how is it possible ?
    And the next question, how can I get the full url so I can parse it myself ?

  • Problem in retriving the realpath from the servlet

    Hai All,
    I am facing problem in retriving the realpath from the servlet.
    I am using the following code in order to retrieve the path.
    String prefix = getServletContext().getRealPath("/WEB-INF/classes");
    The value returned from above code is null.
    I am using Weblogic 8.1 server, and deploying my servlet as WAR file inside
    the weblogic server.
    Is this the problem with the weblogic server or with the code. Is there any way to over come this.
    I need the path as i am implementing Log4j for the servlet and i have to pass the
    configuration file in one of the function "PropertyConfigurator.configure(file);"
    where the file should include complete path.
    My configuration file is in WEB-INF/Classes directory.
    Any help is appreciated.
    Thanks in advance
    Pooja.

    String realPath = request.getRealPath(request.getContextPath());
    That should return the path up to where you have your servlet context.

  • Rep-0002 : unable to retrive string from report builder message file

    rep-0002 : unable to retrive string from report builder message file
    i'm using developer/2000 ver 2.1 and my reports running under win95 platform and i'm using client/server techneque, when i start to distribute my reports to my users on their machines i got the above message , and i have to recompile all of my RDF files again on every user machine. this not all my story , but after some period may be 2 months these reports start to give the same message , again i must recompile all my RDF on every user machine.
    please if any one have a solution for this mazing problem.
    thank you.
    [email protected]

    bogdom and gaben,
    I belong to your club too it seems. Though in my case the compilation was required on each database. Report used to work in the only that database in which they were compiled. Connecting to other database used to give this string error. Moreover this problem existed only for those reports in which i had used PL/SQL code in the formula columns. One way to avoid this is by writing all PL/SQL code in a library and call it in the formula column calculations.
    null

  • Problem in using String in Implicit Cursor

    Hi,
    I am facing problem in using String in Implicit Cursor:
    I have initialise
    DECLARE
    v_grant varchar2(4000);
    begin
    v_grant:='SELECT TABLE_NAME FROM DUMP_USER_TABLES WHERE TABLE_NAME LIKE ';
    FOR obj IN (SELECT v_grant||'''BS%''' FROM dual) LOOP
    V_REVOKE:='REVOKE ALL ON ' || 'obj.TABLE_NAME' || ' FROM ' || '''TEST''';
    DBMS_OUTPUT.PUT_LINE('THE REVOKE STATEMENT IS'||V_REVOKE);
    num := num + 1;
    END LOOP;
    END;
    I am not getting the value from obj.TABLE_NAME its coming as 'obj.TABLE_NAME'
    Kindly anyhelp will be needful for me

    Besides from what Sybrand already pointed out clearly:
    Your example doesn't run at all:
    MHO%xe> DECLARE
      2  v_grant varchar2(4000);
      3  begin
      4  v_grant:='SELECT TABLE_NAME FROM DUMP_USER_TABLES WHERE TABLE_NAME LIKE ';
      5  FOR obj IN (SELECT v_grant||'''BS%''' FROM dual) LOOP
      6  V_REVOKE:='REVOKE ALL ON ' || 'obj.TABLE_NAME' || ' FROM ' || '''TEST''';
      7  DBMS_OUTPUT.PUT_LINE('THE REVOKE STATEMENT IS'||V_REVOKE);
      8  num := num + 1;
      9  END LOOP;
    10  END;
    11  /
    V_REVOKE:='REVOKE ALL ON ' || 'obj.TABLE_NAME' || ' FROM ' || '''TEST''';
    FOUT in regel 6:
    .ORA-06550: line 6, column 1:
    PLS-00201: identifier 'V_REVOKE' must be declared
    ORA-06550: line 6, column 1:
    PL/SQL: Statement ignored
    ORA-06550: line 7, column 49:
    PLS-00201: identifier 'V_REVOKE' must be declared
    ORA-06550: line 7, column 1:
    PL/SQL: Statement ignored
    ORA-06550: line 8, column 1:
    PLS-00201: identifier 'NUM' must be declared
    ORA-06550: line 8, column 1:
    PL/SQL: Statement ignoredI guess you need to read up on quoting strings properly and probably also dynamic SQL.
    But:
    WHAT are you trying to do anyway?
    I cannot parse your code at all...so what is your requirement in human language?

  • Problem with output string to command

    hey i have no idea why this aint working
    its a simple output string to command.
    what it is supposed to do is make a new directory given by the input string
    e.g. mkdir /home/luke/dep
    thanks for the help
    //methods input save files
         saveFile = JOptionPane.showInputDialog("Save Files To : ");
         //method command for saving files
         //Stream to write file
         FileOutputStream fout;          
         try { Process myProcess = Runtime.getRuntime().exec("mkdir" + saveFile );
          InputStreamReader myIStreamReader = new InputStreamReader(myProcess.getInputStream());
          fout = new FileOutputStream ("file.txt");
          while ((ch = myIStreamReader.read()) != -1) { new PrintStream(fout).print((char)ch); } }
              catch (IOException anIOException) { System.out.println(anIOException); }

    What you fail to understand is that "aint working" and "Problem with output string to command" tells us absolutely squat about what your problem is. This is the same as saying to the doctor "I'm sick" and expecting him to cure you. As mentioned by Enceph you need to provide details. Do you get error messages? If so post the entire error and indicate the line of code it occurs on. Do you get incorrect output? Then post what output you get, what output you expect. The more effort you put into your question the more effort others will put in their replies. So until you can manage to execute a little common sense then the only responses you will get will be flames. Now is your tiny little brain able to comprehend that?

  • Comma problem with global string variable

    Hi,
    I'm fiighting with comma problem for global string variable. I've on page string for example "7nndqrr52vzyb,0" and by dynamic column link I'm assigning this string to global variable. Then I'm trying to display value of that global variable on another page but I see only string till comma, nothings more. I'm not sure what I'm doing wrong because when I'm trying to assign that value normally by computation process as a constant value is fine and see on another page correct string. I'll be really glad for help.
    Thanks
    Cheers,
    Mariusz

    When it tries to display the string, it sees the comma and wants to believe the string is terminated. You could escape the , in the string or replace it with a different character..
    See this link: http://download.oracle.com/docs/cd/E17556_01/doc/user.40/e15517/concept.htm#BEIGDEHF
    Thank you,
    Tony Miller
    Webster, TX
    If vegetable oil is made of vegetables, what is baby oil made of?
    If this question is answered, please mark the thread as closed and assign points where earned..

  • Problems deleting a string from an external file.

    hi!
    I am working on a program but am having problems deleting a string of information from an external file. The code I have managed to do only seems to be deleting the surname. The rest of the string remains and the Surname from the string bellow the one that should have been deleted moves to where the surname that was just deleated was.
    this is the code snippet that should be deleting the string:
              System.out.print("Please enter the last name of the contact: ");
              last_name = dataInput.next();
              int z = 0;
              for (int i=0; i < number_of_records; i++)
                        if ((last_name.compareTo(lastName)) < i && (last_name.compareTo(lastName[i]) > i))
                                  z = i;
              for (int i = z; i < number_of_records; i++)
                        lastName[i] = lastName[i+1];
    Anyone got any ideas why its not deleting the whole string?
    the extrenal file is set out like:
    surname,,first name,,phone number

    I don't think you have given enough information to answer this question completely; however, here is my guess:
    The code that appears to be doing the "deleting"
    for (int i = z; i < number_of_records; i++)
        lastName[i] = lastName[i+1];
    }is only acting upon the lastName array.

  • A problem about a string length of the JTextField.

    Hi, all.
    I have a problem of check the length of the text in the JTextField. Look at the following program snippet.
    import javax.swing.text.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.event.DocumentListener;
    import javax.swing.event.DocumentEvent;
    public class test extends JFrame
    JTextField jTextField1 = new JTextField(50);
    static final int MAX_LENGTH = 10;
    public static void main(String[] asArgs)
    test testFrm = new test();
    testFrm.setVisible(true);
    class newDocument extends PlainDocument
    public void insertString(int offs,String str,AttributeSet a) throws
    BadLocationException
    String strTmp;
    strTmp = jTextField1.getText();
    int nSize1 = strTmp.getBytes().length;
    int nSize2 = str.getBytes().length;
    if(nSize1 + nSize2 > MAX_LENGTH)
    return;
    else
    super.insertString(offs,str,a);
    public test() {
    try {
    jbInit();
    catch(Exception e) {
    e.printStackTrace();
    private void jbInit() throws Exception {
    jTextField1.setText("");
    this.getContentPane().add(jTextField1, BorderLayout.NORTH);
    newDocument myDocument = new newDocument();
    jTextField1.setDocument(myDocument);
    public void removeUpdate(DocumentEvent e)
    jTextField1.setText(sOldStr);
    System.out.println("removeUpdate");
    Attention please: I want to check the bytes of the inputted string. It is no problem with english string inputting, but if I input a string with other charset such as A Japanese string or a Chinese string, it doesn't work(when your input string is as long as the MAX_LENGTH, it doesn't work well). How can solve it? Thank you very much.

    i believe the problem is that you didn't set the font of the JTextField.
    I don't know what's the default Font of the JTextField is (i think it's dialog)
    the default textfield cannot display chinese character (and mort unicode character - latin 2 - extends and above).
    You need to set the font that can handle displaying the CHinese & Japanese characters (however, your application may not work if you port your app to another computer..and they don't have the font that you specified (unless you ship the font with it))
    // why are you getting converting the String to byte and then get the length???
    int nSize1 = jTextField1.getText( ).length();

  • Problem reading a string:Plz help

    hi gurus
    I am reading some files (in a loop written by some other program). I am reading them line by line and I tokenize each line by space using split function.
    split(" ");
    In resultant string array, somewhere I found NULL or nothing , for example, I print all tokens and it prints like this
    ?penguins/nns? // I print ?on both sides to check any spaces
    ?march/nnp?
    ?? // now here is problem.. both ? combined..nothing between them
    I have checked the file.. this problem occurs where there are multiple spaces between tokens of a line...if I remove others and keep one space it works..
    Now I want to implement a check in program i.e. where there is SPACE or NULL, I should not process it but It does not work
    Please help
    Edited by: kimskams on Sep 30, 2008 4:51 AM

    Thanks a Lot Sir
    There is another problem that I am facing now..
    I am using this statement
    while ( (rec=dis.readLine() ) != null )to read a line from a file. What I have observed is that if there is a gap between two line then it stops executing file there and even does not go for further files..
    Can you identify the problem or better solution
    thanks

  • Problem using & inside string in a query

    hi all, i have a problem with one of my query.
    i try using an & inside a string in a query and sqlplus and toad prompt me to enter a value. it is reconizing it as input. this is my query
    select department_name from dept where dept_name = 'S&R';
    how can write this query without sqlplus/toad asking me to enter a value for :R
    i tried to escape & by using 'S\&R' but nothing happen.

    In SQL*Plus you SET DEFINE OFF like this:
    SQL> set define off
    SQL> select 'S&R' from dual;
    'S&
    S&R(can't help you with Toad)

  • Problems with the Strings Urgent Help needed

    I have a unique problem. I have to retrieve a particular value from a String. I tried using String tokeniser but in vain. I cannot use java.util.regex package to match the expressions as the version of java on the client m/c is 1.1.8 and they are not ready to upgrade the same.
    The string From which I have is a very long one running into more than 100 lines which can vary from case to case all I know is to retrieve the value which is just in front of "TestValue" which occur only once in the String Can Anybody suggest a bettter alternative.
    Thanx.
    ebistrio

    StringTokenize on TestValueHow would you suggest that was done?
    As I understand it StringTokenizer tokens = new StringTokenizer(string, "TestValue"); would not tokenize on the string "TestValue" but on any of the characters 'T', 'e', 's', 't', 'V', 'a', 'l' or 'u'. This is a common java pitfall in my opinion due to bady named parameters (I feel it should be called "delims" not "delim") or in other people's opinion due to bad parameter type (should be a char[] not a string).
    A clearer explanation of the problem would help.

  • Problem with host string

    hi
    i am new here
    2 days ago i was finish my database administrator course.-it mean that is the first course from 6(as much i know)
    first you should know that english is not my lang so if i will maskes i am sorry
    anyway after i am talking about me i will talk about my problem
    i am trying to connect to sqlplus
    after i click on this tool i get
    user name:
    pass:
    host string:
    i know that i need to go to the file tnsnames.ora and take from there the host string
    i did that and after the parameter "host=" i saw the host string name.
    after i did that i tried to connect with sysdba but without pass cuase if i conn with sysdba i dont need pass
    in "host string " i write the host string accurding to the tnsnames.ora ang it doesn't work
    as aresult i get a line that ask me the pass what sould i do?
    tasks to all of you![b]

    "Host string" entry to connect through SQL*Plus is the SID entry from the tnsnames. Not the parameter host=...
    This is the first parameter, something else like the following :
    DEMO92 =
      (DESCRIPTION =
        (ADDRESS_LIST =...The host which you said is the hostname which is the host of the database, not thedatabase itself.
    Nicolas.

  • The problem with the strings Convert each other

    Hello all,
      Could you help me to solve the following problem using LV7.1? Thank in advance.
      How can I convert a string of "hexadecimal value" with Normal display style to other string of " the same hexadecimal value" with Hex display style?
    Best regards,
    Evan_Lv  

    Hi Evan,
    look at the attachment
    At the moment there is no error checking (any characters other than (0-9|A-F|a-f) will give an error; only even number of chars is converted). You can do the error checking as an exercise on your own!
    Message Edited by GerdW on 08-21-2007 09:08 AM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome
    Attachments:
    HexString.vi ‏22 KB

Maybe you are looking for

  • Sender Mail adapter encounters MalformedInputException

    I have a sender mail adapter that processes the attached .csv file.  All is working fine.  I use FCC in module to convert the attachment and pass to an IDOC adapter for processing in SAP system. My problem is sometimes the sender mail CC fails with .

  • Validation check for BP external id type and id number

    Hi, I need to validate the external Id type and Id no. ( from table BUT0ID) based on some conditions from the WebUI while adding a new id type and also during deletion of that id. I have found out 2 Badi's BUPA_IDENT_UPDATE, BUPA_IDENT_CHECK Will the

  • Photoshop CS5 Video Render Never Finishes; Mac and Windows

    Hello, I've tried rendering a video using Photoshop CS5 and it never finishes. The progress bar reaches the end but the process never completes. The video is only three seconds long (it's the video rendering exercise in Adobe Photoshop CS5: Classroom

  • Process Sheduler for Linux

    Hello, We have to create a monitoring application which shall take some corrective action if required on Linux servers. This shall monitor if the service is running or not after a fixed time interval. If the target service is not running, it shall ta

  • Cant edit DAS Object

    I followed the instructions from the CoolSolutions article http://www.novell.com/coolsolutions/tip/8019.html and had Radius working fine. I am implementing a new server and using ConsoleOne I am trying to edit the DAS object to allow a new client con