第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Android讀取文本原始資源文件

Android讀取文本原始資源文件

猛跑小豬 2019-08-12 16:25:21
Android讀取文本原始資源文件事情很簡(jiǎn)單,但不能按原樣運(yùn)作。我有一個(gè)文本文件作為原始資源添加。文本文件包含如下文本:b)如果適用法律要求對(duì)軟件提供任何擔(dān)保,則所有此類擔(dān)保的有效期限為交付日期后的第九十(90)天。(c)虛擬定向,其經(jīng)銷商,經(jīng)銷商,代理商或雇員提供的任何口頭或書面信息或建議均不構(gòu)成保證或以任何方式增加此處提供的任何保證的范圍。(d)(僅限美國)某些州不允許排除默示擔(dān)保,因此上述排除條款可能不適用于您。本擔(dān)保賦予您特定的法律權(quán)利,您可能還擁有其他法律權(quán)利,這些權(quán)利因國家/地區(qū)而異。在我的屏幕上,我有這樣的布局:<LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"                      android:layout_width="fill_parent"                       android:layout_height="wrap_content"                       android:gravity="center"                       android:layout_weight="1.0"                      android:layout_below="@+id/logoLayout"                      android:background="@drawable/list_background">              <ScrollView android:layout_width="fill_parent"                         android:layout_height="fill_parent">                     <TextView  android:id="@+id/txtRawResource"                                 android:layout_width="fill_parent"                                 android:layout_height="fill_parent"                                android:padding="3dip"/>             </ScrollView>       </LinearLayout>讀取原始資源的代碼是:TextView txtRawResource= (TextView)findViewById(R.id.txtRawResource);txtDisclaimer.setText(Utils.readRawTextFile(ctx, R.raw.rawtextsample);public static String readRawTextFile(Context ctx, int resId){     InputStream inputStream = ctx.getResources().openRawResource(resId);     ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();     int i;     try {         i = inputStream.read();         while (i != -1)         {             byteArrayOutputStream.write(i);             i = inputStream.read();         }         inputStream.close();     } catch (IOException e) {         return null;     }     return byteArrayOutputStream.toString();}文本得到了顯示,但在每一行后我得到一個(gè)奇怪的字符[]如何刪除該字符?我認(rèn)為這是新線。
查看完整描述

3 回答

?
蕭十郎

TA貢獻(xiàn)1815條經(jīng)驗(yàn) 獲得超13個(gè)贊

如果使用基于字符的BufferedReader而不是基于字節(jié)的InputStream,該怎么辦?

BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));String line = reader.readLine();while (line != null) { ... }

不要忘記readLine()跳過新線!


查看完整回答
反對(duì) 回復(fù) 2019-08-12
  • 3 回答
  • 0 關(guān)注
  • 504 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)