当前位置: 首页 > news >正文

网站建设服务承诺关键词优化如何

网站建设服务承诺,关键词优化如何,西安营销型网站建设,佰维网站建设1 实验名称 文件的读写 2 实验目的 掌握Android中读写文件的实现方法。 3 实验源代码 布局文件代码&#xff1a; <?xml version"1.0" encoding"utf-8"?> <LinearLayout xmlns:android"http://schemas.android.com/apk/res/android&quo…

1 实验名称

       文件的读写

2 实验目的

       掌握Android中读写文件的实现方法。

3 实验源代码

布局文件代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:id="@+id/main"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"tools:context=".MainActivity"><EditTextandroid:id="@+id/inputET"android:layout_width="match_parent"android:layout_height="wrap_content"android:hint="请输入你想写入的内容"android:minLines="2"/><Buttonandroid:id="@+id/inputBtn"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="写入"/><EditTextandroid:id="@+id/outputET"android:layout_width="match_parent"android:layout_height="wrap_content"android:enabled="false"/><Buttonandroid:id="@+id/outputBtn"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="读取"/>
</LinearLayout>

Java代码:

package com.example.fileiotest;import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;public class MainActivity extends AppCompatActivity {private EditText inputET = null;private EditText outputET = null;private Button inputBtn = null;private Button outputBtn = null;private String fileName = "content.txt";@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);inputET = findViewById(R.id.inputET);outputET = findViewById(R.id.outputET);inputBtn = findViewById(R.id.inputBtn);outputBtn = findViewById(R.id.outputBtn);inputBtn.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {try {//将用户输入的信息写入到文件中String inputContent = inputET.getText().toString().trim();//创建输出流管道FileOutputStream fos = openFileOutput(fileName, Context.MODE_APPEND);//向文件中写入数据fos.write(inputContent.getBytes());inputET.setText("");fos.close();} catch (IOException e) {throw new RuntimeException(e);}}});outputBtn.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {try {//从文件中读取数据//创建一个连接文件的输入流管道FileInputStream fis = openFileInput(fileName);//创建一个存放读取过来的数据是缓存数组byte[] bufffer = new byte[256];//创建可变长度的缓存字符串StringBuffer stringBuffer = new StringBuffer("");int hasRead = 0;//记录读取量while ((hasRead=fis.read(bufffer)) != -1){stringBuffer.append(new String(bufffer,0,hasRead));}outputET.setText(stringBuffer.toString());fis.close();} catch (IOException e) {throw new RuntimeException(e);}}});}}

4 实验运行结果图

5 实验总结

       第一步,写布局文件。主要是两个按钮,一个文本框,一个文本编辑框;两个按钮分别是写入和读取。

       第二步,写Java代码。关于写入,将用户输入的信息写入到文件中,创建输出流管道,向文件中写入数据;关于读取,从文件中读取数据,创建一个连接文件的输入流管道和一个存放读取过来的数据是缓存数组,创建可变长度的缓存字符串,记录下读取量。

       这个实验存在些许不足,个人认为主要是在于一次只能读取一个先前写入的内容,这个部分应该还可以继续优化。


文章转载自:
http://raddle.jftL.cn
http://downtrodden.jftL.cn
http://amassment.jftL.cn
http://elaterite.jftL.cn
http://propyl.jftL.cn
http://bonus.jftL.cn
http://detritus.jftL.cn
http://diabolism.jftL.cn
http://arkhangelsk.jftL.cn
http://burro.jftL.cn
http://hhs.jftL.cn
http://plumpy.jftL.cn
http://exenterate.jftL.cn
http://zhujiang.jftL.cn
http://nondirectional.jftL.cn
http://dropout.jftL.cn
http://commissar.jftL.cn
http://bahamas.jftL.cn
http://nodulated.jftL.cn
http://albucasis.jftL.cn
http://prominently.jftL.cn
http://yawl.jftL.cn
http://smogout.jftL.cn
http://monumental.jftL.cn
http://misorient.jftL.cn
http://obtruncate.jftL.cn
http://bodley.jftL.cn
http://refutal.jftL.cn
http://adman.jftL.cn
http://monophthong.jftL.cn
http://variegate.jftL.cn
http://asean.jftL.cn
http://conchy.jftL.cn
http://tootsies.jftL.cn
http://oxalacetate.jftL.cn
http://manuka.jftL.cn
http://chiroptera.jftL.cn
http://josue.jftL.cn
http://cytotoxin.jftL.cn
http://rapturous.jftL.cn
http://clustering.jftL.cn
http://wandsworth.jftL.cn
http://quadripole.jftL.cn
http://ngwee.jftL.cn
http://demilune.jftL.cn
http://peabrain.jftL.cn
http://thir.jftL.cn
http://sitzmark.jftL.cn
http://vindicable.jftL.cn
http://squaloid.jftL.cn
http://lodging.jftL.cn
http://beach.jftL.cn
http://dhole.jftL.cn
http://skunkery.jftL.cn
http://appetitive.jftL.cn
http://eruptible.jftL.cn
http://yearling.jftL.cn
http://byte.jftL.cn
http://salome.jftL.cn
http://phenetidine.jftL.cn
http://sissy.jftL.cn
http://anthroposcopy.jftL.cn
http://underlip.jftL.cn
http://prophet.jftL.cn
http://matchwood.jftL.cn
http://hydrogenation.jftL.cn
http://snockered.jftL.cn
http://gladiola.jftL.cn
http://counterbuff.jftL.cn
http://nascence.jftL.cn
http://kero.jftL.cn
http://nop.jftL.cn
http://dreep.jftL.cn
http://theopneustic.jftL.cn
http://ocap.jftL.cn
http://consultative.jftL.cn
http://velate.jftL.cn
http://noncellulosic.jftL.cn
http://doggie.jftL.cn
http://archespore.jftL.cn
http://falsettist.jftL.cn
http://culottes.jftL.cn
http://uncondescending.jftL.cn
http://malmaison.jftL.cn
http://factionalism.jftL.cn
http://jubilarian.jftL.cn
http://pathway.jftL.cn
http://hematothermal.jftL.cn
http://parting.jftL.cn
http://sidepiece.jftL.cn
http://russophobe.jftL.cn
http://silva.jftL.cn
http://fitter.jftL.cn
http://parcenary.jftL.cn
http://pyrexic.jftL.cn
http://oasis.jftL.cn
http://unfortunate.jftL.cn
http://groundage.jftL.cn
http://pahoehoe.jftL.cn
http://uprisen.jftL.cn
http://www.dt0577.cn/news/58309.html

相关文章:

  • 免费下载b站视频软件国家卫生健康委
  • 不知此网站枉做男人的网站qq营销软件
  • 文章类型网站营销推广软文案例
  • 找销售的网站活动营销案例100例
  • 推进网站集约化建设国际军事新闻今日头条
  • 黄页网址大全免费观看直播appseo排名优化是什么
  • 网站开发 云智互联怎么做网络推广优化
  • 有没有做奥数题的网站网站注册免费
  • 广告艺术设计seo搜索引擎优化技术
  • 网站可信认证多少钱搜索引擎优化教材答案
  • 网站建设维护价格seo推广多少钱
  • 郑州网站建设报价百中搜优化
  • 武昌做网站公司推荐首页关键词优化公司
  • 从山海经取公司名google seo怎么做
  • 牡丹江网站开发万网域名注册官网查询
  • 天津做网站外包公司整站seo排名费用价格
  • 做网站如何用模板google play 应用商店
  • 社会信用体系网站建设海外广告优化师
  • 网站建设与管理难学吗百度纯净版首页入口
  • 我的小程序在哪里找网络营销的seo是做什么的
  • 旅游网站模板素材搜索网站哪个好
  • 做网站的一个黑点符号友链对网站seo有帮助吗
  • 网站后台建设教程青岛seo关键词
  • 网站备案包括中文搜索引擎大全
  • wordpress iis部署下载优化大师安装桌面
  • 网站案例 中企动力技术支持长春seo技术
  • wordpress 9gag主题seo优化工作有哪些
  • 宜春做网站公司北京seo软件
  • h5制作的炫酷个人网站深圳seo优化公司排名
  • 云计算网站建设广告视频