软件开发领域都关心。
分类: Java
2010-02-20 11:21:33
String strReturn =
"";InputStream is;
int iRead = 0; int maxLen = end - start; int leftRead = maxLen; int loopRead = 0; try { //System.out.println("Get file name " + resource);is = getClass().getResourceAsStream(resource);
is.skip(start);
//jump to start position //loop to read file do{loopRead = leftRead > 1024?1024:leftRead;
iRead = is.read(word_utf, 0, loopRead );
//System.out.println("iRead " + iRead); if(iRead <= 0){ //no more data in file, end of read break;}
String tmp =
new String(word_utf, 0, iRead, "UTF-16BE");strReturn = strReturn + tmp;
leftRead = leftRead - loopRead;
if(leftRead <= 0){ //no data left, end of read break;}
}
while(iRead == 1024);is.close();
}
catch (IOException ex) {System.
out.println(ex);}
return strReturn;}