[rules-users] Error Loading Multiple Input Files

Swindells, Thomas TSwindells at nds.com
Mon Jun 7 09:51:54 EDT 2010


This isn't really a Drools question just a basic java programming question.
You are trying to read your input files from the current working directory (which defaults to the root of your project in eclipse).
What you probably want to be doing is reading your files from the classpath instead.  Using ResourceFactory.newClassPathResource is the way I normally go about reading my files but you can do it with the standard class loader methods as well.

Thomas

From: rules-users-bounces at lists.jboss.org [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Fnu Mahalakshmi
Sent: 07 June 2010 14:42
To: 'rules-users at lists.jboss.org'
Subject: Re: [rules-users] Error Loading Multiple Input Files

Hi Greg,

I have my input files inside the src directory of my eclipse project.

I am passing the files as follows:
private static final String DATA_INPUT_FILE = new String []{ "Input1.txt", "Input2.txt"};

private static final String DATA_OUTPUT_FILE = "Output.1.txt";

private static final String RULES_FILES = new String [] {"Rule1.drl", "Rules2.drl"};

public static void main(String[] args) throws Exception {
BufferedReader input =  new BufferedReader(new FileReader(DATA_INPUT_FILE));
       Converter c = new Converter(DATA_INPUT_FILE); // this reads my input files
          Vector<Object> v  = new Vector<Object>();
          v = c.getFactInput();                     // loads all information contained in the input files

          new RuleRunner().runStatelessRules(RULES_FILES,null, v,null);                               FileOutputStream output = new FileOutputStream(DATA_OUTPUT_FILE);


Error Log:

Exception in thread "main" java.io.FileNotFoundException: Input1.txt (The system cannot find the file specified)
      at java.io.FileInputStream.open(Native Method)
      at java.io.FileInputStream.<init>(Unknown Source)
      at java.io.FileInputStream.<init>(Unknown Source)
      at java.io.FileReader.<init>(Unknown Source)
      at com.org.RulesTest.main(RulesTest.java:29)


Can you tell me why that happens??
The file is present.
Thanks.
M
________________________________

Please consider the environment before printing this email.

Visit our website at http://www.nyse.com
*****************************************************************************
Note: The information contained in this message and any attachment to it is privileged, confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender immediately by replying to the message, and please delete it from your system. Thank you. NYSE Euronext.



________________________________

**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster at nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100607/a24dc501/attachment.html 


More information about the rules-users mailing list