Quote:
Originally Posted by ihor
well, since I fixed my problem now, I would like to tell what I am trying to do.
Here is the code:
Spoiler:
Code:
package com.amazon.ebook.booklet.reader.resources;
import java.util.ListResourceBundle;
import java.util.*;
import java.io.*;
public class ReaderResources_en_US extends ListResourceBundle
{
static final Object a[][];
private static String fontSizesStringDefault = "15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35";
private static int fontSizesDefault[] = new int[] { 15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35 };
private static String fontLetterDefault = "a";
private static int[] fontSizes = fontSizesDefault;
private static String fontLetter = fontLetterDefault;
private static void readConfig()
{
FileInputStream fis = null;
try {
fis = new FileInputStream("/mnt/us/system/com.amazon.ebook.booklet.reader/fontfix.pref");
Properties p = new Properties();
p.load(fis);
fontLetter = p.getProperty("FONT_LETTER", "a");
String sizes = p.getProperty("FONT_SIZES", fontSizesStringDefault);
String sArray[] = sizes.split(",");
fontSizes = new int[sArray.length];
for (int i = 0; i < sArray.length; ++i) {
fontSizes[i] = Integer.parseInt(sArray[i]);
}
}
catch (Exception e)
{
fontLetter = fontLetterDefault;
fontSizes = fontSizesDefault;
}
try {
if (fis != null) {
fis.close();
}
}
catch (IOException ex) {}
}
public ReaderResources_en_US()
{
}
static
{
readConfig();
a = (new Object[][] {
new Object[] {
"mobireader.default.font.size.list", fontSizes
}
});
}
public Object[][] getContents()
{
return a;
}
}
when I comment the line readConfig(); in static constructor - it works fine: I see my font sizes with just letter a.
when I uncomment the line readConfig();, I see - to my surprise - OLD SET OF FONT SIZES. As if there are no absolutely en_US resource.
Question: why does it happen? It seems as if java runtime doesn't want to load this class when it sees a method call in static constructor. but why?
I am not a java programmer, so if anyone can help with this - I'll be grateful.
|
Check the system logfile. There's probably an unchecked exception being thrown somewhere. Hint: try to catch Throwable, instead of Exception.
As to the code, there is nothing that looks immediately wrong. My guess is the String.split() method - the Kindles do not support regexes (I have also been bitten by this a few times). Try to use a StringTokenizer instead. And note that Integer.parseInt() may also throw an unchecked exception.