一个J2ME上关于IO流的问题
我的目的是想访问放在本地的XML文件
InputStream is = getClass().getResourceAsStream("/city.xml"); int length = 0; try { while (is.read() != -1) { length++; }// byte[] info = new byte[592892]; byte[] info = new byte[length]; is.read(info); System.out.println(new String(info)); } catch (IOException e) { e.printStackTrace(); }
InputStream is = getClass().getResourceAsStream("/city.xml");try { byte[] info = new byte[is.available()]; is.read(info, 0, is.available()); System.out.println(new String(info, "GB2312")); } catch (IOException e) { }