Friday, March 23, 2012

Access path to asset txt file

InputStream is = getResources().getAssets().open("terms.txt");
String textfile = convertStreamToString(is);

public static String convertStreamToString(InputStream is)
throws IOException {
Writer writer = new StringWriter();

char[] buffer = new char[2048];
try {
Reader reader = new BufferedReader(new InputStreamReader(is,
"UTF-8"));
int n;
while ((n = reader.read(buffer)) != -1) {
writer
.write(buffer, 0, n);
}
} finally {
is.close();
}
String text = writer.toString();
return text;
}

Thursday, March 22, 2012

Failed to Load the JNI shared Library (JDK)

Use OS and Eclipse both 64 bit or 32 bit and confi eclipse.ini like this

-startup
plugins/org.eclipse.equinox.launcher_1.1.1.R36x_v20101122_1400.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.2.R36x_v20101222
-showsplash
org.eclipse.platform
-vm
C:/Program Files/Java/jdk1.6.0_32/jre/bin
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx512m