码迷,mamicode.com
首页 > 其他好文 > 详细

载入着色器的异常

时间:2017-07-24 18:56:32      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:ring   内容   except   utf-8   round   int   style   cat   trace   

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;
		
		
	}
假设红色部分被屏蔽后,会导致载入着色器不成功。

载入着色器的异常

标签:ring   内容   except   utf-8   round   int   style   cat   trace   

原文地址:http://www.cnblogs.com/wzzkaifa/p/7230249.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!