Basics4ME Project
Introduction
Basics4ME is a framework providing missing features for J2ME platform.
- J2SE missing features:
- BufferedInputStream, BufferedReader, FilteredInputStream
- Properties loading
- Helper classes:
- System utility
- Url utility
- Char utility
- Boolean utility
Code samples
Parse boolean string value :
BooleanUtil.parseBoolean("true");
BooleanUtil.parseBoolean("false");Parsing boolean string value/ignore case :
BooleanUtil.parseBoolean("TRUE");
BooleanUtil.parseBoolean("FALSE");Testing if a character is awhite space :
CharUtil.isWhitespace(' ');Obtaining System property with fallback to a default value :
SystemUtil.getProperty("system.key.1", "default value");Opening Http Url input stream :
try {
InputStream is = UrlUtil.openStream("http://basics4me.helyx.org/index.html");
try {
int intValue = -1;
while((intValue = is.read()) >= 0) {
System.out.println((char)intValue);
}
}
finally {
is.close();
is = null;
}
}
catch(Throwable t) {
t.printStackTrace();
}Opening Classpath Url input stream :
try {
InputStream is = UrlUtil.openStream("/org/helyx/basics4me/test/test-content.properties");
try {
int intValue = -1;
while((intValue = is.read()) >= 0) {
System.out.println((char)intValue);
}
}
finally {
is.close();
is = null;
}
}
catch(Throwable t) {
t.printStackTrace();
}Loading values from Classpath Url input stream :
try {
InputStream is = UrlUtil.openStream("/org/helyx/basics4me/test/test-content.properties");
assertNotNull(is);
try {
Properties properties = new Properties();
properties.load(is);
assertEquals("test.value", properties.get("test.key"));
assertNull(properties.get("test.key.1"));
}
finally {
is.close();
is = null;
}
}
catch(Throwable t) {
t.printStackTrace();
}Loading values from classpath ressource using BufferedReader with method readLine :
try {
InputStream is = UrlUtil.openStream("/org/helyx/basics4me/test/test-content.properties");
assertNotNull(is);
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
try {
String line = null;
while((line = br.readLine()) != null) {
System.out.println(line);
}
}
finally {
br.close();
br = null;
isr = null;
is = null;
}
}
catch(Throwable t) {
t.printStackTrace();
}Maven integration
Adding Helyx.org repositories
<repositories>
<repository>
<id>Helyx.org - Release repository</id>
<url>http://maven.helyx.org/repository/release</url>
</repository>
<!-- Uncomment following lines, if you want to use snapshot repository -->
<!--
<repository>
<id>Helyx.org - Snapshot repository</id>
<url>http://maven.helyx.org/repository/releases</url>
</repository>
-->
</repositories>
Adding Basics4ME dependency
<dependency>
<groupId>org.helyx</groupId>
<artifactId>basics4me</artifactId>
<version>1.0.5</version>
</dependency>