listing15-06_resourcereader.java_wrong

来自「着几乎所有智能机厂商都将有自己配套的App Store,甚至并非智能手机制造商的」· JAVA_WRONG 代码 · 共 23 行

JAVA_WRONG
23
字号
Listing 15-6. Reading a Resource Incorrectly

public class ResourceReader {

	public byte[] readResource( String url )
	throws IOException
	{
		InputStream in = getClass().getResourceAsStream( url );

		// the following always returns 0 on Symbian and Motorola:
		int available = in.available();
		byte[] buffer = new byte[ available ];

		// this is not guaranteed to work either:
		in.read( buffer );

		// the input stream is not guaranteed to be closed,
		// since in.read() may throw an exception.
		in.close();
		return buffer;
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?