合并字节流
2017-02-15 19:43
113 查看
合并字节流实现加载指定位置的国际化文件
public static String getLangValue2(String path, String key, String lang) { Locale locale = new Locale(lang); if (lang.indexOf("_") > 0) { String[] lans = lang.split("_"); locale = new Locale(lans[0], lans[1]); } SequenceInputStream sis = null; InputStreamReader reader = null; String msg = ""; try { String resourceKey = pathKey(path, locale); ResourceBundle rb = RESOURCE_CACH.get(resourceKey); if (rb == null) { String proFilePath = Const.servletRealPath + path; rb = new RootResourceBundle(proFilePath, locale, "UTF-8"); String defFilePath = Const.servletRealPath + path + ".properties"; if (StringUtils.isBlank(lang)) { proFilePath += ".properties"; } else { proFilePath += "_" + locale + ".properties"; } InputStream is1 = new FileInputStream(defFilePath); InputStream is2 = new FileInputStream(proFilePath); sis = new SequenceInputStream(is1, is2); reader = new InputStreamReader(sis, "UTF-8"); RESOURCE_CACH.put(resourceKey, rb); is1.close(); is2.close(); } msg = rb.getString(key); // msg = new String(msg.getBytes("ISO-8859-1"), "UTF-8"); } catch (UnsupportedEncodingException e) { Logger.exception(e); } catch (MissingResourceException e) { Logger.exception(e, "Can't find key " + key); msg = ""; } catch (Exception e) { Logger.exception(e); msg = ""; } finally { try { if (sis != null) { sis.close(); sis = null; } if (reader != null) { reader.close(); reader = null; } } catch (IOException e) { Logger.exception(e); } } return msg; }
相关文章推荐
- 用带缓冲的字节流合并音乐
- 黑马程序员-探究字节流四(应用文件切割合并)
- 简单的两个文件合并【字节流】
- 多服务器访问日志合并脚本
- poj 3253 贪心 同 合并果子
- 已知两个链表 la和 lb,其元素值递增排序。编程将la和lb合并成一个递减有序(相同值元素只保留一个)的链表lc。(北方名校经典试题) 本题选做
- 内存流转字节,字符串转字节,字节合并
- 【数据结构练习】2.两个有序链表序列的合并
- 如何实现文件的分割与合并?
- 用ul li实现边框重合并附带鼠标经过效果
- Unity mesh 合并
- 输入字节流与输出字节流
- excel sheet合并 宏初学
- PDF合并
- IOS开发实现二张图片合并http://ios.662p.com/thread-1350-1-1.html
- MeteoInfoLab脚本示例:合并数组
- 字节流和字符流
- 创建与合并分支命令
- 【分享】javascript合并混淆压缩
- Linux文件的合并、排序和分割