摘要: public class ReadFromFile { /** * 以字节为单位读取文件,常用于读二进制文件,如图片、声音、影像等文件。 */ public static void readFileByBytes(String fileName) { File file = new File(fileName); InputStream in = null; try { System.out.println("以字节为单位读取文件内容,一次读一个字节:"); // 一次读一个字节 in = new FileInputStream(file); int tempbyte; w 阅读全文
posted @ 2013-11-25 13:51 五谷丰登 阅读(191) 评论(0) 推荐(0)
摘要: 在Unicode和UTF-8之间转换 try {// Convert from Unicode to UTF-8String string = "abc\u5639\u563b";byte[] utf8 = string.getBytes("UTF-8");// Convert from UTF-8 to Unicodestring = new String(utf8, "UTF-8");} catch (UnsupportedEncodingException e) {}------------------------------- 阅读全文
posted @ 2013-11-25 12:41 五谷丰登 阅读(3703) 评论(0) 推荐(0)