diff --git a/Doc/Sd1/appendix.xml b/Doc/Sd1/appendix.xml index ed54d613f68ad6c0a01c3f9ec30dedf2cb1c4716..acf7e815e85d7f5ae717417f26d62328b07e35e2 100644 --- a/Doc/Sd1/appendix.xml +++ b/Doc/Sd1/appendix.xml @@ -408,15 +408,75 @@ inputSecond.txt</programlisting> ./Sda1/Jdom/Html2Html/src/main/resources/imageExample.html</programlisting> <tip> - <para/> - <orderedlist> <listitem> - <para/> + <para>Read about reading from files by using instances of + <classname + xlink:href="http://www.tutorialspoint.com/java/io/bufferedreader_readline.htm">java.io.BufferedReader</classname>.</para> + </listitem> + + <listitem> + <para>Reading from standard input may be achieved by:</para> + + <programlisting language="java">final BufferedReader source = new BufferedReader(new InputStreamReader(System.in)); +...</programlisting> </listitem> <listitem> - <para/> + <para>You may create an executable jar archive using Maven. + Starting from the <code>mi-mavem-archetype-quickstart</code> your + <filename>pom.xml</filename> already contains a blueprint. Just + insert your class containing the entry + <methodname>main(...)</methodname> method (i.e. + <classname>de.hdm_stuttgart.mi.sd1.grep.Grep</classname> in the + current example) accordingly:</para> + + <programlisting language="xml"><plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-shade-plugin</artifactId> + <version>2.4.1</version> + <configuration> + <transformers> + <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> + <manifestEntries> + <Main-Class><emphasis role="bold">de.hdm_stuttgart.mi.sd1.grep.Grep</emphasis></Main-Class> + </manifestEntries> + </transformer> + </transformers> + </configuration> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>shade</goal> + </goals> + </execution> + </executions> +</plugin></programlisting> + + <para>Running <command>mvn</command> <option>install</option> will + create an executable jar file + <filename>~/.m2/repository/de/hdm-stuttgart/mi/sd1/grep/0.9/grep-0.9.jar</filename> + with <quote>~</quote> denoting your home directory. You may then + create a simple shell wrapper script <filename>mygrep</filename> + (don't forget to supply execute permission) hiding the + <command>java</command> execution stuff:</para> + + <programlisting language="none">#!/bin/sh + +# A simple wrapper hiding java execution stuff. + +# Do not forget to make this file executable by issuing "chmod ugo+x mygrep" + +java -jar ~/.m2/repository/de/hdm-stuttgart/mi/sd1/grep/0.9/grep-0.9.jar $* + +#end</programlisting> + + <para>You my now simply invoke your application. The following + example reads from standard input by virtue of a pipe:</para> + + <programlisting language="none">> cat Testdata/input.txt | ./bin/mygrep red +The red cross acts worldwide</programlisting> </listitem> </orderedlist> </tip>