0

I want to run SWI-Prolog from Java file. I want to read text.pl file and write the output in output.txt file. How can I do that? I'm not pretty sure of what I did here if it is correct or not. I'm not familiar with the command line calling. This is the Java code:

public class Example
{
         public static void main(String[] args)
         {
            SystemCommandsRunner scr = new SystemCommandsRunner();
            scr.runCommand("swipl -f input.pl < input.pl > output.txt");
         }
}
4

2 回答 2

0

http://www.swi-prolog.org/packages/jpl/java_api/

我可能会建议你使用它,它是 prolog 和 java 的双向 API

我很久以前试过了,效果很好

于 2013-05-03T11:58:28.977 回答
0

您可以使用Runtime.getRuntime().exec("swipl -f input.pl < input.pl > output.txt");

于 2013-05-03T02:34:19.907 回答