Skip to content

Commit

Permalink
adding a resource example
Browse files Browse the repository at this point in the history
  • Loading branch information
searchivarius committed Oct 9, 2014
1 parent 5279a6c commit d382847
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 0 deletions.
11 changes: 11 additions & 0 deletions read_resource_example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
An example of using a (resource) dictionary from inside of an install maven jar
===================================================================================
Usage. First, install the dictionary. Go to the folder **dict-resource**, type:
```
mvn install
```
Then go to the directory **dict-user**, then type:
```
mvn exec:java -Dexec.mainClass=test
```
The content of the dictionary file should be printed. For details, study the file **dict-user/src/main/java/test.java**
2 changes: 2 additions & 0 deletions read_resource_example/dict-resource/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
all:
mvn clean install
19 changes: 19 additions & 0 deletions read_resource_example/dict-resource/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>dict-resource</artifactId>
<version>2.0</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
accordingly
across
actually
after
again
allows
anyw
4 changes: 4 additions & 0 deletions read_resource_example/dict-user/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
all:
mvn compile
run:
mvn clean compile exec:java -Dexec.mainClass=test
26 changes: 26 additions & 0 deletions read_resource_example/dict-user/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>dict-user</artifactId>
<version>1.0</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>test</groupId>
<artifactId>dict-resource</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
</project>
Binary file not shown.
12 changes: 12 additions & 0 deletions read_resource_example/dict-user/src/main/java/test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import java.io.*;
public class test {
public static void main(String args[]) throws Exception {
InputStream is =
test.class.getClassLoader().getResourceAsStream("dict.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(is, "utf-8"));
String ln;
while ((ln = br.readLine()) != null) {
System.out.println(ln);
}
}
};

0 comments on commit d382847

Please sign in to comment.