![](images/chestnut/misc/code_html.gif)
import java.io.*;
import java.util.Hashtable;
public class ResourcesUTF8
{
public ResourcesUTF8(String s, String s1, String s2)
{
buffer = new StringBuffer();
endFile = false;
fileName = null;
extenssion = "";
load = false;
error = false;
extenssion = s2;
load = false;
name = s1;
directory = '/' + (s != null && s.trim().length() != 0 ? s + '/' : "");
}
public String get(String s)
{
if(!load && !load())
return "";
String s1 = (String)hashtable.get(s);
if(s1 == null)
return "";
else
return s1;
}
public void unload()
{
hashtable = null;
if(fileName != null)
{
name = null;
extenssion = null;
directory = null;
}
load = false;
endFile = true;
buffer = null;
}
public boolean load()
{
InputStream inputstream;
if(error)
return false;
inputstream = null;
InputStream inputstream1;
boolean flag;
inputstream1 = getInputStream();
if(inputstream1 != null)
break MISSING_BLOCK_LABEL_37;
flag = false;
if(inputstream != null)
try
{
inputstream.close();
}
catch(IOException ioexception) { }
return flag;
boolean flag1;
inputstream = new DataInputStream(inputstream1);
hashtable = new Hashtable();
endFile = false;
buffer = new StringBuffer();
for(String s = readKey(inputstream); s != null; s = readKey(inputstream))
{
String s1 = s.trim();
if(s1.length() > 0)
{
String s2 = readValue(inputstream);
if(s2 != null)
hashtable.put(s1, s2.trim());
}
}
inputstream.close();
load = true;
flag1 = true;
if(inputstream != null)
try
{
inputstream.close();
}
catch(IOException ioexception1) { }
try
{
return flag1;
}
catch(Exception exception)
{
error = true;
}
unload();
flag = false;
if(inputstream != null)
try
{
inputstream.close();
}
catch(IOException ioexception2) { }
return flag;
Exception exception1;
exception1;
if(inputstream != null)
try
{
inputstream.close();
}
catch(IOException ioexception3) { }
throw exception1;
}
private InputStream getInputStream()
{
if(error)
return null;
if(fileName == null)
{
InputStream inputstream = null;
String s = System.getProperty("microedition.locale");
if(s != null)
{
s = s.replace('-', '_');
fileName = directory + name + "_" + s + "." + extenssion;
inputstream = getClass().getResourceAsStream(fileName);
if(inputstream != null)
return inputstream;
int i = s.indexOf('_');
if(i != -1)
{
s = s.substring(0, i);
fileName = directory + name + "_" + s + "." + extenssion;
inputstream = getClass().getResourceAsStream(fileName);
if(inputstream != null)
return inputstream;
}
}
fileName = directory + name + "." + extenssion;
inputstream = getClass().getResourceAsStream(fileName);
if(inputstream == null)
{
error = true;
unload();
return null;
} else
{
return inputstream;
}
} else
{
return getClass().getResourceAsStream(fileName);
}
}
private String readKey(DataInputStream datainputstream)
throws IOException
{
if(endFile)
return null;
buffer.setLength(0);
int i;
for(i = -1; (i = datainputstream.read()) > 0 && i != 10 && i != 61;)
{
char c = (char)i;
buffer.append(c);
}
if(i == -1)
{
endFile = true;
return null;
} else
{
return buffer.toString();
}
}
private String readValue(InputStream inputstream)
throws IOException
{
if(endFile)
return null;
buffer.setLength(0);
for(int i1 = 0; (i1 = inputstream.read()) > 0 && i1 != 10;)
{
int i = i1 & 0xff;
switch(i >> 4)
{
case 0: // '\0'
case 1: // '\001'
case 2: // '\002'
case 3: // '\003'
case 4: // '\004'
case 5: // '\005'
case 6: // '\006'
case 7: // '\007'
buffer.append((char)i);
break;
case 12: // '\f'
case 13: // '\r'
int j = getByte(inputstream);
if((j & 0xc0) != 128)
throw new UTFDataFormatException();
buffer.append((char)((i & 0x1f) << 6 | j & 0x3f));
break;
case 14: // '\016'
int k = getByte(inputstream);
int l = getByte(inputstream);
if((k & 0xc0) != 128 || (l & 0xc0) != 128)
throw new UTFDataFormatException();
buffer.append((char)((i & 0xf) << 12 | (k & 0x3f) << 6 | (l & 0x3f) << 0));
break;
case 8: // '\b'
case 9: // '\t'
case 10: // '\n'
case 11: // '\013'
default:
throw new UTFDataFormatException();
}
}
return buffer.toString();
}
private int getByte(InputStream inputstream)
throws IOException, UTFDataFormatException
{
int i = inputstream.read();
if(i < 0 || i == 10)
{
endFile = true;
throw new UTFDataFormatException();
} else
{
return i;
}
}
public static final char DELIMITER = 61;
private Hashtable hashtable;
private StringBuffer buffer;
private boolean endFile;
private String fileName;
private String directory;
private String extenssion;
private String name;
private boolean load;
private boolean error;
}
![](images/chestnut/misc/code_html.gif)
import java.io.*;
import java.util.Hashtable;
public class ResourcesUTF8
{
public ResourcesUTF8(String s, String s1, String s2)
{
buffer = new StringBuffer();
endFile = false;
fileName = null;
extenssion = "";
load = false;
error = false;
extenssion = s2;
load = false;
name = s1;
directory = '/' + (s != null && s.trim().length() != 0 ? s + '/' : "");
}
public String get(String s)
{
if(!load && !load())
return "";
String s1 = (String)hashtable.get(s);
if(s1 == null)
return "";
else
return s1;
}
public void unload()
{
hashtable = null;
if(fileName != null)
{
name = null;
extenssion = null;
directory = null;
}
load = false;
endFile = true;
buffer = null;
}
public boolean load()
{
InputStream inputstream;
if(error)
return false;
inputstream = null;
InputStream inputstream1;
boolean flag;
inputstream1 = getInputStream();
if(inputstream1 != null)
break MISSING_BLOCK_LABEL_37;
flag = false;
if(inputstream != null)
try
{
inputstream.close();
}
catch(IOException ioexception) { }
return flag;
boolean flag1;
inputstream = new DataInputStream(inputstream1);
hashtable = new Hashtable();
endFile = false;
buffer = new StringBuffer();
for(String s = readKey(inputstream); s != null; s = readKey(inputstream))
{
String s1 = s.trim();
if(s1.length() > 0)
{
String s2 = readValue(inputstream);
if(s2 != null)
hashtable.put(s1, s2.trim());
}
}
И соответсвенно,word.txt и tran.txt
![:-)](images/smilies/grins.gif)
Это Mobilelexicon.