File: FrenchDeconjugatorTester.java

package info (click to toggle)
verbiste 0.1.49-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 4,260 kB
  • sloc: xml: 24,823; ansic: 9,087; sh: 5,258; cpp: 4,480; makefile: 1,021; yacc: 288; perl: 281; lisp: 215; java: 47; sed: 16
file content (77 lines) | stat: -rw-r--r-- 2,102 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*  $Id: FrenchDeconjugatorTester.java,v 1.2 2012/11/18 19:56:04 sarrazip Exp $
    FrenchDeconjugatorTester.java - Test for the french-deconjugator command

    verbiste - French conjugation system
    Copyright (C) 2003 Pierre Sarrazin <http://sarrazip.com/>

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
*/

import java.io.*;


public class FrenchDeconjugatorTester
{
    public static void main(String[] args)
    {
	String cmd = "french-deconjugator";

	if (args.length > 0)
	    cmd = args[0];

	try
	{
	    Process process = Runtime.getRuntime().exec(cmd);

	    OutputStreamWriter w = new OutputStreamWriter(
						process.getOutputStream());
	    BufferedReader r = new BufferedReader(
			    new InputStreamReader(process.getInputStream()));

	    BufferedReader in = new BufferedReader(
					new InputStreamReader(System.in));
	    String inputLine;

	    while ((inputLine = in.readLine()) != null)
	    {
		inputLine.trim();
		w.write(inputLine + "\n");
		w.flush();

		String received;
		while ((received = r.readLine()) != null)
		{
		    if (received.length() == 0)
			break;
		    System.out.println("\t" + received);
		}
	    }
	    w.close();
	    r.close();
	    process.destroy();
	}
	catch (IOException e)
	{
	    System.out.println(cmd + ": " + e.getMessage());
	    System.exit(1);
	}
	catch (Exception e)
	{
	    System.out.println("Error: " + e.getMessage());
	    System.exit(1);
	}
    }
}