Home Download Change log

Introduction

Sometimes it is required to parse a string like it can be done with the C scanf(). I developed a similar function for Java with the extension that this parser can also handle strings enclosed in " or ' correctly.

Features

Requirements

Examples

public class StringParserDemo
{
  public static void main(String[] args)
  {
    String s = "Hello World: \"how are you?\" - 123 4.5";
    Object[] data = new Object[3];

    if (StringParser.parse(s,"Hello World: %S - %d %f",data,StringParser.QUOTE_CHARS))
    {
      System.out.printf("%s\n",(String)data[0]);
      System.out.printf("%d\n",(Integer)data[1]);
      System.out.printf("%f\n",(Double)data[2]);
    }
  }
}

Compile

Just import StringParser in your Java application source code.

Note: please have a look in StringParser.java for details!

License

StringParser is currently under GPL version 2.

Download

StringParser.java

ChangeLog

2009-09-15 0.02
  * add number format exception handler
2008-11-12 0.01
  * initial public release
      

    
Back to top