Results 1 to 2 of 2

Thread: [RESOLVED]Retrieve product number from SDF file

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2006
    Posts
    21

    Resolved [RESOLVED]Retrieve product number from SDF file

    I have a sdf file, i wan to retrieve product numbers from the file. However, when i print out, it only printed out the first product number(02230416222D). There are supposed to be 2 products numbers, does anyone knows why my program only loop 1 time?
    This is how the sdf file looks like:
    Code:
      -ISIS-  02230416222D
    
     17 18  0  0  0  0  0  0  0  0999 V2000
    
    ......
    $$$$//this is end of the first product
      -ISIS-  02230416222D
    
     17 18  0  0  0  0  0  0  0  0999 V2000
    ......
    $$$$ //this is the end of second product
    This is my java program:
    Code:
    Scanner inFile = new Scanner(new FileReader("merlin3.sdf"));
    while(inFile.hasNext("-ISIS-"))
    {
    	String line = inFile.nextLine();
    	String pdt = line.replaceAll("-ISIS-","");
    	String pdtNo = pdt.trim();
    	System.out.println(pdtNo);
    }
    Last edited by huiling25; Jan 22nd, 2007 at 04:30 AM.

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Dec 2006
    Posts
    21

    Re: HELP!!Retrieve product number from SDF file

    Here is the solution:
    Code:
    while(inFile.hasNext()) {
    	String line = inFile.nextLine();
    	if(line.contains("-ISIS-")) {
    		String pdt = line.replaceAll("-ISIS-","");
    		String pdtNo = pdt.trim();
    		System.out.println(pdtNo);
    	}
    }

Posting Permissions

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



Click Here to Expand Forum to Full Width