载入着色器的异常

public static String loadFromAssetsFile(String fname, Resources r) {
		String result = null;
		
		
		try {
			InputStream in = r.getAssets().open(fname);
			int ch = 0;
			ByteArrayOutputStream baos = new ByteArrayOutputStream();
			<span style="background-color: rgb(255, 0, 0);">while ((ch = in.read()) != -1) {//-1表示着色内容的最后一行
				baos.write(ch);
			}</span>
			System.out.println(ch);
			byte[] buff = baos.toByteArray();
			baos.close();
			in.close();
			result = new String(buff, "UTF-8");
			result = result.replaceAll("\\r\\n", "\n");
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
		
		
	}
假设红色部分被屏蔽后,会导致载入着色器不成功。
posted @ 2017-07-24 17:56  wzzkaifa  阅读(231)  评论(0编辑  收藏  举报