Results 1 to 2 of 2
  1. #1
    pavan528 is offline Member
    Join Date
    Sep 2012
    Posts
    13
    Rep Power
    0

    Default Converting Range Statements to Sets in Java

    I am trying to Extract the ranges of Variables from a Text File. I extracted lines of the forms X in 1..10 Y in 12..50 Z in 0..19 / 66/ 95..100 Where X in 1 ..10 states that X takes values from set 1 to 10 Similarly for Y and for Z its a Union of different ranges of the values (0 to 19, union 66,union 95 to 100)

    I want to Map these Variables to their respective sets using Hashmap where Key is Variable name and value will be a Set. My Hashmap Signature is HashMap> hm=new HashMap>();

    Java Code:
      while((line=br.readLine())!=null)
                {
                    Matt=Patt.matcher(line);
                    if(Matt.find())
                    {
                        //System.out.println(line);
                        String []s=line.split(" ");
                        String range=s[2];
                        RangeMatt=RangePatt.matcher(range);
                         System.out.println("Range =" + range);
                        while(RangeMatt.find())
                        {
                            System.out.println(RangeMatt.group());
                        }
                       
                        //hm.put(s[0], S);
                    }
                }
    I am stuck at extracting the variables ranges from these plain strings. Can anyone help me here with their expertise?

    Thanks,
    Last edited by pavan528; 03-20-2014 at 02:02 AM.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,391
    Rep Power
    25

    Default Re: Converting Range Statements to Sets in Java

    Please post the code you are having problems with and the contents of the file that the code is reading.
    Be sure to wrap the code in code tags:

    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Java runtime error: String index out of range.
    By whatson in forum New To Java
    Replies: 4
    Last Post: 08-22-2012, 09:32 AM
  2. Replies: 2
    Last Post: 05-07-2012, 06:31 PM
  3. Replies: 2
    Last Post: 01-07-2011, 11:50 AM
  4. Replies: 0
    Last Post: 07-12-2010, 11:57 AM
  5. Java Collection Framework (Sets)
    By Java Tutorial in forum Java Tutorial
    Replies: 0
    Last Post: 12-07-2007, 07:50 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •