Problems parsing a string

Hi,
I'm having a problem with parsing a string. Basically, I want to take a string for example: "TomWentToTheShop" and divide it into a coherent sentence (Tom went to the shop).
I've started the code by breaking the string into a char array, and if the character is a capital then store the index in the array and then do a substring.
But I don't think this is the best way to solve the problem, if anyone has any ideas it would be greatly appreciated.
thanks.
char[] charRequestTypeArray = string.toCharArray();
for (int i = 1; i < (charRequestTypeArray.length -1); i++) {
char c = charRequestTypeArray;
if (Character.isUpperCase(c)) {
Arrays.fill(storeCapitalIndex, i);
else{
Arrays.fill(storeNonCapitalIndex, i);

        String s = "TomWentToTheShop";
        System.out.println(s.charAt(0) + s.substring(1).replaceAll("((?<!^)[A-Z])", " $1").toLowerCase());or even just        System.out.println(s.charAt(0) + s.substring(1).replaceAll("([A-Z])", " $1").toLowerCase());Edited by: sabre150 on Nov 11, 2007 9:40 PM

Similar Messages

  • Is there a problem on the pattern of SimpleDateFormat to parse a String ?

    Hello,
    I tried to parse a String to a Date using a SimpleDateFormat.
    I must be able to have on the pattern something like : "yyyyMMdd_HH00".
    To get a String from a Date with SimpleDateFormat.format(Date date) it works well, but when a try to parse a String into a Date with SimpleDateFormat.parse(String date) I get a : java.text.ParseException: Unparseable date.
    I try it on a JVM 1.4 and 1.5 for the same result.
    An exemple of code :
              String pattern = "yyyyMMdd_HH00";
              SimpleDateFormat currentFormat = new SimpleDateFormat(pattern);
              Date date = currentFormat.parse("20091223_1000");It seems that adding the '00' after 'HH' raise the exception...
    Has the 'HH00' a particular meaning like on Oracle 'HH24' ?
    Is there a way to add number after the 'HH' ?
    Thanks
    Edit :
    Oh yeah, I forgot, I tryied to use the pattern "yyyyMMdd_HH'00'" using '' to escape the 00 without better result...
    Edited by: Jeremy.Antonucci on 23 déc. 2009 15:25

    The context of this pattern :
    To get a file on a http server, I must build an Url String with a filename using the current date.
    I want to be able to change easily the pattern on a file parameters.
    The date must be ending with 00 for the minutes.
    I may have use a pattern with 'HHmm' and suppress the minutes but if it is change on the futur the code will not work...
    As I can't say if in the futur the url will change for the date pattern or not, I decide to use a pattern like "yyyyMMdd_HH00" that works fine for everything else than parsing a string.
    I create a String date based on the current date on UTC using this pattern and keep it to use it to compose an Url String.
    After I need to know how much time I must sleep before the next execution (on each Hour), so I use this date +1 hour to see if the currentDate during this calculation is higher than this date+1... (I'm surely not clear, but it is not the real problem just for curious ^^)
    A dirty solution is to avoid this problem is to catch this case and do substitution on a temporary pattern of the 'HH00' with 'HHmm'. It's really dirty because nothing says that later a 'HH00' mean always 'HHmm' but I have nothing better...
              String pattern2 = pattern;
              if (pattern.matches(".*HH00$")) {
                   pattern2=pattern.substring(0, (pattern.length()-2))+"mm";
              }Where can I do this bug report ?
    Do you see a good solution ?

  • Parsing a string using StringTokenizer

    Hi,
    I want to parse a string such as
    String input = ab{cd}:"abc""de"{
    and the extracted tokens should be as follows
    ab
    cd
    "abc""de"
    As a result, I used the StringTokenizer class with deilmeter {,},:
    StringTokenizer tokenizer = new StringTokenizer(input,"{}:", true);
    In this was, I can separate the tokens and also can get the delimeters. The problem is I don't know how to parse the string that has double quote on it. If a single quote " is taken as a delimeter then
    ", abc, ",", de," all of them will be taken as a separate token. My intention is to get the whole string inside the double quote as a token including the quotes on it. Moreover, if there is any escape character "", it should be also included in the token. Help please.
    Thanks

    A bit of a "sticky tape"-solution...
    import java.util.StringTokenizer;
    public class Test {
        public static void main(String[] args) {
            String input = "ab{cd}:\"abc\"\"de\"";
            StringTokenizer st = new StringTokenizer(input, "{}:", true);
            while(st.hasMoreTokens()) {
            String token = st.nextToken();
            if(token.startsWith("\"") && token.endsWith("\"")) {
            token = token.substring(1,token.length()-1);
                System.out.println(token);
    }

  • Problem parsing an XML

    I have this servlet that should be parsing a string received using a HTTP POST, here is the code of the servlet:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.FactoryConfigurationError;
    import javax.xml.parsers.ParserConfigurationException;
    import org.xml.sax.InputSource;
    import org.w3c.dom.*;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    import org.apache.xml.serialize.*;
    import org.xml.sax.InputSource;
    public class SMSReceiver extends HttpServlet
    public void service(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
    try {
    //Initialization for the servlet
    ServletInputStream entrada = req.getInputStream();
    ServletOutputStream salida = res.getOutputStream();
    //Reading of the entering string
    BufferedReader lector = new BufferedReader(new InputStreamReader (entrada));
    res.setContentType("text/HTML");
    try {
    DocumentBuilderFactory factory =
    DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    InputSource inStream = new InputSource();
    inStream.setCharacterStream(new StringReader(lector.readLine()));
    Document doc1 = builder.parse(inStream);
    NodeList listasms = doc1.getElementsByTagName("sms");
    for(int s=0; s<listasms.getLength() ; s++)
    Node nodosms = listasms.item(s);
    if(nodosms.getNodeType() == Node.ELEMENT_NODE)
    Element elementosms = (Element)nodosms;
    NodeList listatelf = elementosms.getElementsByTagName("tlf");
    Element elementotelf = (Element)listatelf.item(0);
    NodeList textTelfList = elementotelf.getChildNodes();
    String telefono = ((Node)textTelfList.item(0)).getNodeValue();
    salida.println("Telefono" + telefono);
    NodeList listaop = elementosms.getElementsByTagName("op");
    Element elementoop = (Element)listaop.item(0);
    NodeList textOpList = elementoop.getChildNodes();
    String operadora = ((Node)textOpList.item(0)).getNodeValue();
    NodeList listasc = elementosms.getElementsByTagName("sc");
    Element elementosc = (Element)listasc.item(0);
    NodeList textSCList = elementosc.getChildNodes();
    String shortcode = ((Node)textSCList.item(0)).getNodeValue();
    NodeList listabody = elementosms.getElementsByTagName("body");
    Element elementobody = (Element)listabody.item(0);
    NodeList textBodyList = elementobody.getChildNodes();
    String body = ((Node)textBodyList.item(0)).getNodeValue();
    catch (SAXParseException err)
    salida.println ("** Parsing error" + ", line " + err.getLineNumber () + ", uri " + err.getSystemId ());
    salida.println(" " + err.getMessage ());
    catch (SAXException e)
    Exception x = e.getException ();
    ((x == null) ? e : x).printStackTrace ();
    catch (Throwable t)
    t.printStackTrace ();
    The error I get from the servlet is:
    ** Parsing error, line 1, uri null
    XML document structures must start and end within the same entity.
    Finished executing
    Here's the code of the program that sends the HTTP POST:
    import java.io.*;
    import java.net.*;
    import java.io.*;
    public class HTTPSender {
    public static void main(String[] args) throws Exception {
    try {
    String cadena = ""
    + "<root>\n"
    + "<sms>\n"
    + "<tlf>" + (URLEncoder.encode("4123161640" , "UTF-8")) + "</tlf>\n"
    + "<op>" + (URLEncoder.encode("D" , "UTF-8")) + "</op>\n"
    + "<sc>" + (URLEncoder.encode("0000" , "UTF-8")) + "</sc>\n"
    + "<body>" + (URLEncoder.encode("PRUEBA DE MENSAJE MOVIL+" , "UTF-8")) + "</body>\n"
    + "</sms>\n"
    + "</root>";
    //URL url = new URL("http://200.74.214.222:8080/MovilPlus/MovilPlusResponse");
    URL url = new URL("http://localhost:8080/SMSconnector/SMSReceiver");
    int i = 0;
    while (i!=1) {
    URLConnection conn = url.openConnection();
    conn.setDoOutput(true);
    OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
    wr.write(cadena);
    wr.flush();
    // Get the response
    BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    String line;
    while ((line = rd.readLine()) != null) {
    System.out.println(line);
    wr.close();
    rd.close();
    i = i + 1;}
    } catch (Exception e) {
    Now anybody could tell me WHAT I'M DOING WRONG???? Please, need real help here. I'm JAVA newbie but in desperation. Thanks!

    Yes, that's the problem kcounsel, thanks for your help, now I'm parsing I modified my code to store the data into a DATABASE, the problem is that it's not storing and neither giving me any exception for the DB, here's the code to see if you can manage something here:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.BufferedReader;
    import java.io.FileWriter;
    import java.io.PrintWriter;
    import java.io.File;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.FactoryConfigurationError;
    import javax.xml.parsers.ParserConfigurationException;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    import org.w3c.dom.*;
    import org.apache.xml.serialize.*;
    import java.net.URLDecoder;
    import java.sql.*;
    import org.xml.sax.InputSource;
    import java.io.StringReader;
    * This class is made as a servlet for receiving strings and saving
    * them as DB records and XML files, it will save each sms in a different XML
    * generating the automatic number of the SMS.
    * <p>Bugs: (None untill now, please notify if you find one)
    * @author (Helder Martins ([email protected]))
    public class SMSReceiver extends HttpServlet
    //Public variables we will need
    public String Stringid;
    public String Stringpath;
    public String st;
    public int nid;
    //Servlet service method, which permits listening of events
    public void service(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
    //Initialization for the servlet
    ServletOutputStream salida = res.getOutputStream();
    ServletInputStream entrada = req.getInputStream();
    try {
    //Reading of the entering string
    BufferedReader lector = new BufferedReader(new InputStreamReader (entrada));
    res.setContentType("text/HTML");
    //Database handler
    Class.forName("org.gjt.mm.mysql.Driver");
    Connection Conn = DriverManager.getConnection ("jdbc:mysql://localhost:3306/smsdb","root", "");
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    InputSource inStream = new InputSource(entrada);
    Document doc1 = builder.parse(inStream);
    NodeList listasms = doc1.getElementsByTagName("sms");
    for(int s=0; s<listasms.getLength() ; s++)
    Node nodosms = listasms.item(s);
    if(nodosms.getNodeType() == Node.ELEMENT_NODE)
    Element elementosms = (Element)nodosms;
    NodeList listatelf = elementosms.getElementsByTagName("tlf");
    Element elementotelf = (Element)listatelf.item(0);
    NodeList textTelfList = elementotelf.getChildNodes();
    String telefono = ((Node)textTelfList.item(0)).getNodeValue();
    //String SendingAddress = ((Node)textAddressList.item(0)).getNodeValue().trim();
    salida.println("Telefono " + telefono);
    NodeList listaop = elementosms.getElementsByTagName("op");
    Element elementoop = (Element)listaop.item(0);
    NodeList textOpList = elementoop.getChildNodes();
    String operadora = ((Node)textOpList.item(0)).getNodeValue();
    salida.println("Operadora " + operadora);
    NodeList listasc = elementosms.getElementsByTagName("sc");
    Element elementosc = (Element)listasc.item(0);
    NodeList textSCList = elementosc.getChildNodes();
    String shortcode = ((Node)textSCList.item(0)).getNodeValue();
    salida.println("Shortcode " + shortcode);
    NodeList listabody = elementosms.getElementsByTagName("body");
    Element elementobody = (Element)listabody.item(0);
    NodeList textBodyList = elementobody.getChildNodes();
    String body = ((Node)textBodyList.item(0)).getNodeValue();
    salida.println("Body " + body);
    Statement sta = Conn.createStatement();
    sta.executeUpdate("INSERT INTO smstable (telf,op,sc,body) VALUES ('" + telefono + "','" + operadora + "','" + shortcode + "','" + body + "')");
    Conn.commit();
    Conn.close();
    //Catching errors for the SAX and XML parsing
    catch (SAXParseException err)
    salida.println ("** Parsing error" + ", line " + err.getLineNumber () + ", uri " + err.getSystemId ());
    salida.println(" " + err.getMessage ());
    catch (SAXException e)
    Exception x = e.getException ();
    ((x == null) ? e : x).printStackTrace ();
    catch (Throwable t)
    t.printStackTrace ();

  • 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?

  • How to parse xml string

    Hi! I'm having problems parsing an xml string. I've done DOM and SAX parsing before. But both of them either parse a file or data from an input source. I don't think they handle strings. I also don't want to write the string into a file just so I can use DOM or SAX.
    I'm looking for something where I could simply do:
    Document doc = documentBuilder.parse( myXMLString );
    So the heirarchy is automatically established for me. Then I could just do
    Element elem = doc.getElement();
    String name = elem.getTagName();
    These aren't the only methods I would want to use. Again, my main problem is how to parse xml if it is stored in a string, not a file, nor comming from a stream.
    thanks!

    But both of them either parse a file or data from an input source. I don't think they handle strings.An InputSource can be constructed with a Reader as input. One useful subclass of Reader is StringReader, so you'd use something likeDocument doc = documentBuilder.parse(new InputSource(new StringReader(myXMLString)));

  • Parsing a string in PL/SQL?

    I am parsing a string in PL/SQL and at a certain point(Length 45) of the string I would like to add a carriage return (Chr(10)), then continue with the string at that point and then again if the string is greater than Length 45 add a carriage return.
    I program in Powerbuilder and have figured it out, but I have a problem when trying to add a carriage return at a certain point in the string in PL/SQL. There is the REPLACE(), but that will replace everything, but I only want to add it at that certain point of the string. With the PB function I can add the carriage return at a certain point, see code:
    Li_pos = PosA( Ps_data, '*')
    DO WHILE Li_pos > 0
    ll_length = Li_pos - ll_old_pos
    IF ll_length > 45 THEN
    ll_old_pos = Li_pos
    Ps_data = ReplaceA( Ps_data, Li_Pos, 1, ls_carriage_rtn) **This function gives me the ability to add a carriage return at a certain point in the string. **
    Li_pos = PosA( Ps_data, '*', Li_pos + 1 + ls_carriage_rtn)
    ELSE
    Li_pos = PosA( Ps_data, '*', Li_pos + 1)
    END IF
    LOOP
    I have incorporated the same logic in PL/SQL but I am looking for something similar to the ReplaceA function in PB, that will replace at a certain point in a string. I use an '*' as a placeholder and measure the length. Below is the PL/SQL code:
    t_pos NUMBER;
    t_old_pos NUMBER;
    t_length NUMBER;
    BEGIN
    t_old_pos := 0;
    t_pos := INSTR(in_model_list, '*');
    WHILE t_pos > 0 LOOP
    t_length := t_pos - t_old_pos; -- This looks at current position minus the old position, measures the length
    IF t_length > 45 THEN
    t_old_pos := t_pos;
    *** add that carriage return
    t_pos := INSTR(in_model_list, '*', t_pos + 1 + Chr(10)); -- get the new position
    NULL;
    ELSE
    t_pos := INSTR(in_model_list, '*', t_pos + 1);
    END IF;
    NULL;
    END LOOP;
    Here is the data, what it looks like: William 112,* 500-A,* 500-U,* 520,* 560-A,* 560-E,* 680-E,* 680-F,* 680-V*
    Any help would be much appreciated.
    Thank you,
    William
    Edited by: William on Feb 28, 2012 6:56 AM

    Frank Kulash wrote:
    [example]I played with your example and came to this:SQL> WITH my_string AS
      2         (SELECT '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'
      3                   AS mt
      4            FROM DUAL)
      5     ,  line_length AS
      6         (SELECT 13 AS chars
      7            FROM DUAL)
      8      SELECT LISTAGG (REGEXP_SUBSTR (mt,'(.{'|| line_length.chars|| '})', 1, LEVEL),chr(10)) WITHIN GROUP (ORDER BY LEVEL)
      9             ||chr(10)
    10             ||substr(mt,-mod(LENGTH (mt),line_length.chars)) as wrapped_text
    11        FROM my_string
    12        CROSS JOIN line_length
    13  CONNECT BY LEVEL < 1+LENGTH (mt) ;
    WRAPPED_TEXT
    1234567890123
    4567890123456
    7890123456789
    0123456789012
    3456789012345
    6789012345678
    9012345678901
    2345678901234
    5678901234567
    8901234567890
    1234567890123
    WRAPPED_TEXT
    4567890123456
    7890
    SQL>*[Edit]* annotated that this is 11g only...
    Edited by: T.PD on 29.02.2012 21:17

  • Parsing hexadecimal strings

    im an fresher currently in a project on secure hash algorithm
    my project is stopped due to certain reasons , further which i cannot proceed.
    i woud be grateful to u if some one provides solution to my problem.
    int a = (word[i] << 1) or (word[i] >> 32-n)
    word is an array that consist of hexadecimal string .
    the thing here is for instance , 0x2g46778, 2g46778
    when u print(both, individually) using System.out.println yields different results.
    the scenario is i have derived word array that consist only number without 0x extension ,
    but result yielded is wrong as for the reason mentioned above.
    but when i take an array that consist of 0x as string and concat it with every element of word array i get the full number (i.e 0x 2hg4kr7)
    again the problem is parsing the hexadecimal string(with ox as extension)
    Query:
    please tell me whether their is any way for parsing hexadecimal string as ox is not recognized.
    or
    how to proceed with it such that my string get parsed.
    thank u
    sincerly
    hari hara ganesh dharmarajan
    india`

    Could you post some sample input and desired output for your project?
    What is an array of hex string?
    Is it String[] with the contents of each string consisting of the char a-f and 0-9? Eg String[] xx = new String[] {"1234", abcd"};
    What does "parsing a hex string" mean? Give an example please.

  • Parsing and String tokenizer

    I am trying to use String Tokenizer to extract fields from a file then do a calculation on some of the fields.
    My problem is when I try to parse the strings that need the calculations I get error codes as shown at the end of post. I don't see why the parsing shouldn't work.( error codes are class expected and incompatable types)
    // ParsingTextFile.java: Process text file using StringTokenizer
    import java.io.*;
    import java.util.StringTokenizer;
    public class ParsingTextFile1 {
      /** Main method */
      public static void main(String[] args) {
       // Declare  buffered file reader and writer streams
       BufferedReader brs = null;
       BufferedWriter bws = null;
       //declare tokenizer
       StringTokenizer tokenizer;
       // Declare a print stream
       PrintWriter out = null;
        // Five input file fields:total string, student name, midterm1,
        // midterm2, and final exam score
        String line=null;
        String sname = null;
       String mid1= null;
        String mid2 = null;
        String finalSc = null;
      /  double midterm1 = 0;
        double midterm2 = 0;
        double finalScore = 0;
        // Computed total score
        double total = 0;
        try {
          // Create file input and output streams 
          brs = new BufferedReader(new FileReader("in.dat"));
          bws = new BufferedWriter(new FileWriter("out.dat"));
         while((line= brs.readLine())!=null){
         tokenizer =new StringTokenizer(line);
          sname = tokenizer.nextToken();
          mid1 = tokenizer.nextToken();
          mid2 = tokenizer.nextToken();
          finalSc= tokenizer.nextToken();
          midterm1 = double.parseDouble(mid1)//this code not working
          midterm2 = double.parseDouble(mid2);)//this code not working
          finalScore = double.parseDouble(finalScore);//this code not working
          out = new PrintWriter(bws);
          total = midterm1*0.3 + midterm2*0.3 + finalScore*0.4;
          out.println(sname + " " + total);
        catch (FileNotFoundException ex) {
          System.out.println("File not found: in.dat");
        catch (IOException ex) {
          System.out.println(ex.getMessage());
        finally {
          try {
            if (brs != null) brs.close();
            if (bws != null) bws.close();
          catch (IOException ex) {
            System.out.println(ex);
    }[\code]
    errorsC:\j2sdk1.4.1_06\bin\ParsingTextFile1.java:43: class expected
        midterm1 = double.parseDouble(mid1);
                          ^
    C:\j2sdk1.4.1_06\bin\ParsingTextFile1.java:44: class expected
        midterm2 = double.parseDouble(mid2);
                          ^
    C:\j2sdk1.4.1_06\bin\ParsingTextFile1.java:45: class expected
        finalScore = double.parseDouble(finalScore);
                            ^
    C:\j2sdk1.4.1_06\bin\ParsingTextFile1.java:43: incompatible types
    found   : java.lang.Class
    required: double
        midterm1 = double.parseDouble(mid1);
                         ^
    C:\j2sdk1.4.1_06\bin\ParsingTextFile1.java:44: incompatible types
    found   : java.lang.Class
    required: double
        midterm2 = double.parseDouble(mid2);
                         ^
    C:\j2sdk1.4.1_06\bin\ParsingTextFile1.java:45: incompatible types
    found   : java.lang.Class
    required: double
        finalScore = double.parseDouble(finalScore);
                           ^
    6 errors
    Process completed.

    while(line.hasMoreTokens())
    sname = tokenizer.nextToken();  
       mid1 = tokenizer.nextToken();   
      mid2 = tokenizer.nextToken();  
       finalSc= tokenizer.nextToken(); 
        midterm1 = double.parseDouble(mid1)//this code not working
         midterm2 = double.parseDouble(mid2);)//this code not working  
       finalScore = double.parseDouble(finalScore);//this code not working
    }if it doesn't work then you need to add delimiter Or the token that you are trying to convert into is not valid.

  • How can I parse a String to Timestamp type??

    Hi, I receive a String time="07.05.2007 12:30:20", I want to parse this String to a Timestamp type, how to do that?

    I use the following code to parse String to Date, but it throw unhandled exception, type parse exception. It seems the parse source "07.05.2007 12:30:10" has problem.
    SimpleDateFormat sdfTest=new SimpleDateFormat("dd.mm.YYYY HH:mm:ss");
         Date newDate=sdfTest.parse("07.05.2007 12:30:10");
    Please give me some suggestion.
    Message was edited by:
    Mellon

  • Parsing xml string does not see the dtd inside jar

    Hello,
    I have problem parsing an XML string because the DTD file is not found (my DTD file is located inside my application's jar file). I am trying to instruct the parser where the DTD is located. If my DTD would have been on the filesystem directlly things would be working just fine, but i need to keep the DTD inside my JAR.
    String dtdLocation = ClassLoader.getSystemResource("mydtd.dtd").toURI().toString();
    Document xmlDocument = builder.parse(new ByteArrayInputStream(xmlFile.getBytes()),dtdLocation);The XML string looks something like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE Properties SYSTEM "mydtd.dtd">
    <Properties>
    <Prop>val<Prop>
    </Properties>

    >
    Hi,
    Don't resurrect old threads, and why on earth did you resurrect 5 threads? I'm locking the zombie threads. Create a new thread if you have a specific question.
    Kaj

  • How can I solve a Parse Error: "There was a problem parsing this package"

    Hello;
    I developed a really simple app in Flash Pro CC for android. I published it using AIR 13.0 for Android. When I tried to install it I received the Parse Error: "There was a problem parsing this package"
    Im not sure if the problem has something to do with my app xml file, but here it is:
    <?xml version="1.0" encoding="UTF-8"?>
    <application xmlns="http://ns.adobe.com/air/application/13.0">
         <id>TOeatorNOTTOeat</id>
         <versionNumber>1.0.0</versionNumber>
         <versionLabel>TouchEvent</versionLabel>
         <filename>TO eat or NOT TO eat</filename>
         <description/>
         <name>TO eat or NOT TO eat</name>
         <copyright/>
         <initialWindow>
              <content>TO%20eat%20or%20NOT%20TO%20eat.swf</content>
              <systemChrome>standard</systemChrome>
              <transparent>false</transparent>
              <visible>true</visible>
              <fullScreen>true</fullScreen>
              <aspectRatio>landscape</aspectRatio>
              <renderMode>gpu</renderMode>
              <autoOrients>false</autoOrients>
         </initialWindow>
         <icon>
              <image36x36>icons/icon36x36.png</image36x36>
              <image48x48>icons/icon48x48.png</image48x48>
              <image72x72>icons/icon72x72.png</image72x72>
              <image96x96>icons/icon96x96.png</image96x96>
         </icon>
         <customUpdateUI>false</customUpdateUI>
         <allowBrowserInvocation>false</allowBrowserInvocation>
        <android>
              <manifestAdditions>
                   <![CDATA[<manifest> </manifest>]]>
              </manifestAdditions>
         </android>
         <supportedLanguages>en</supportedLanguages>
    </application>
    What do you think is the best to check?

    i don't see any problem with your manifest.
    try saving your fla and the published files to a new directory and see if the error resolves.

  • Problem in  Converting String to Date

    Hi All,
    I am having one String
    String date = "2006-01-17 15:19:57.0"
    I want to parse this String into Date object.
    I will really appriciate if somebody helps me out.
    Thanks.

    You're specifying a 'T' and a timezone in your format, but they're not present in the string you're parsing.
    I'm assuming from the way you're printing out the date, that your thinking is along these lines: "sdfInput will parse the input string, no matter what format it's in, and will produce a Date object. That Date object wil have the format specified in sdfInput."
    This is wrong on a couple of fronts:
    1) DateFormat doesn't magically figure out what format it's supposed to use for the String it's parse()ing. The String has to match the DF's format.
    2) Dates don't have formats. Only Strings do. A Date object is just a long. There's no relationship whatsoever between the Date that you get from parse() and the format that was used to produce it. When you print out a Date as you're doing, its toString method is called, which in turn uses a default format for your Locale.
    If you want to turn a date string in one format into a date string in another format, use two different DateFormat objects with two different formats. Date date = df1.parse(inputString);
    String outputString = df2.format(date);

  • How to Parse a string into an XML DOM ?

    Hi,
    I want to parse a String into an XML DOM. Not able to locate any parser which supports that. Any pointers to this?

    Download Xerces from xml.apache.org. Place the relevant JAR's on your classpath. Here is sample code to get a DOM document reference.
    - Saish
    public final class DomParser extends Object {
         // Class Variables //
         private static final DocumentBuilder builder;
         private static final String JAXP_SCHEMA_LANGUAGE =
             "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
         /** W3C schema definitions */
         private static final String W3C_XML_SCHEMA =
             "http://www.w3.org/2001/XMLSchema";
         // Constructors //
         static {
              try {
                   DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                   factory.setNamespaceAware(true);
                   factory.setValidating(true);
                   factory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
                   builder = factory.newDocumentBuilder();
                   builder.setErrorHandler(new ErrorHandler() {
                       public void warning(SAXParseException e) throws SAXException {
                           System.err.println("[warning] "+e.getMessage());
                       public void error(SAXParseException e) throws SAXException {
                           System.err.println("[error] "+e.getMessage());
                       public void fatalError(SAXParseException e) throws SAXException {
                           System.err.println("[fatal error] "+e.getMessage());
                           throw new XmlParsingError("Fatal validation error", e);
              catch (ParserConfigurationException fatal) {
                   throw new ConfigurationError("Unable to create XML DOM document parser", fatal);
              catch (FactoryConfigurationError fatal) {
                   throw new ConfigurationError("Unable to create XML DOM document factory", fatal);
         private DomParser() {
              super();
         // Public Methods //
         public static final Document newDocument() {
              return builder.newDocument();
         public static final Document parseDocument(final InputStream in) {
              try {
                   return builder.parse(in);
              catch (SAXException e) {
                   throw new XmlParsingError("SAX exception during parsing.  Document is not well-formed or contains " +
                        "illegal characters", e);
              catch (IOException e) {
                   throw new XmlParsingError("Encountered I/O exception during parsing", e);
    }- Saish

  • Parsing formatted String to Int

    How can I parse formatted string to Integer ?
    I have a formated string like this $900,000 and I need to convert it to 900000 so I could do calculations with it.
    I tried something like this
    NumberFormat nf = NumberFormat.getIntegerInstance(request.getLocale());
    ttlMargin=nf.parse(screenVal);I got this exception
    "java.lang.NumberFormatException: For input string: "$1,050,000""

    I am working on the JSP file that provides
    margins,sales etc. I am reading this data off the
    screen where it is beeing displayed according to the
    accounting practices.
    That's why I get it as a formatted string and why I
    am trying covert that string to the numberScreen-scraping is a problematic, bad design. It sounds like what you really want is to call a web service which returns its results as data that a program can understand (XML, for example), not HTML (which is meant more for humans to read). I know, you probably can't change the design at this point... just food for thought. In the meantime, you'll probably have to manually parse those strings yourself by stripping out the '$' and ',' characters and then use parseInt on the result.

Maybe you are looking for

  • Make table of contents links keep current zoom level, not zoom out to full page

    When Indesign creates tables of contents, they automatically link to the paragraphs the links point to, so that in an interactive PDF, clicks and prods take the user to that page. Great. What's not so great is, that the hyperlinks / cross-references

  • Weird Slow Perf. - Activity Monitor - Dock Problem

    I have a Powerbook G4 that's been running insanely slow. I went through the troubleshooting steps to fix this, and opened the Activity Monitor to see what's been sucking up all the processing power on the CPU. To my surprise, the Dock application is

  • 11g Production and Fusion Order Demo

    In Part 5 of the Fusion Order Demo, the cue cards describe how to add a bar graph to browseOrders.jspx. Unforutnately, when the graph is added and the orders-flow.xml is run, the graph does not appear and the table "orderItemsTable" displays "No rows

  • Rtp dynamic payload type 123

    Hello, We have a problem about RTP dynamic payload type 123. If you know, please explain when cisco gateways are nagotiation between non-cisco media gateways. When we look at rtp packets, Wireshark tag this packets malformed. Is there a way Can we di

  • Where's the Adobe DNG Converter 4.5 app?

    I downloaded the ACR plugin and the DNG app isn't in the dmg. What gives? http://www.adobe.com/support/downloads/detail.jsp?ftpID=3942