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

个人网站怎么备案新媒体运营哪个培训机构好

个人网站怎么备案,新媒体运营哪个培训机构好,网站上线后,就业创业网站建设目录 1.IO概述1.1流的分类 2.字符流2.1 案例 1.IO概述 IO(Input/Output):输入和输出,指的是某个设备或环境进行数据的输入或者输出。例如:键盘的输入,再比如显示器就是输出设备,输出图像。 对于java来说输…

目录

  • 1.IO概述
    • 1.1流的分类
  • 2.字符流
    • 2.1 案例

1.IO概述

IO(Input/Output):输入和输出,指的是某个设备或环境进行数据的输入或者输出。例如:键盘的输入,再比如显示器就是输出设备,输出图像。
对于java来说输入输出问题,java将它抽象成流对象来解决。
以游戏程序为中心读取文件就是输入,写入文件是输出。

1.1流的分类

IO流在java中从输入输出角度分类:
1.输入流:从数据源读取数据,例如从文件、键盘等读取数据。
2.输出流:将数据写入到目的地,例如写入文件、屏幕等。
IO流在java中从数据的角度来分类:
1.字符流:文本,我们能读的懂的都可以认为是字符流。比如:文章,java文件等等
2.字节流:二进制的数据,这种数据一般用文本打开我们读不懂。比如,图片文件,mp3文件,等等。

2.字符流

文本,我们能读的懂的都可以认为是字符流。比如:文章,java文件等等
字符流
(1)输出流:以 “Writer” 结尾,例如 FileWriterBufferedWriter 等。

在这里插入图片描述

(2)输入流:以 “Reader” 结尾,例如 FileReaderBufferedReader 等。
在这里插入图片描述

字符流的类的命名的规则:
如果是输出流就以Writer结尾
如果是输入流就以Reader结尾

2.1 案例

使用字符流向一个文件输入helloworld。
分析步骤:

  1. 创建文件对象,指定文件路径和名称。
  2. 创建输出流对象,例如 FileWriter
  3. 将输出流指向指定的文件。
  4. 使用输出流对象的 write() 方法写入数据。
  5. 释放资源,关闭输出流

在这里插入图片描述

public class IOTest {public static void main(String[] args) {// 创建文件File file = new File("test.txt");Writer writer = null;try {// 创建输出流对象writer = new FileWriter(file);// 写入数据writer.write("HelloWorld");} catch (IOException e) {e.printStackTrace();} finally {// 关闭输出流if (writer != null) {try {writer.close();} catch (IOException e) {e.printStackTrace();}}}}
}

如果想在已有文件内容的末尾添加数据,可以使用 FileWriter 的构造方法,并传入第二个参数 true,表示追加模式。

public class IOTest4 {public static void main(String[] args) {Writer writer = null;try {//IO流是需要关闭的,如果不这样设计就会不能关闭资源//writer = new FileWriter("test1.txt", true);writer = new FileWriter(new File("test1.txt"), true);writer.write("liangliang");} catch (IOException e) {e.printStackTrace();}finally {//判断writer不是空防止空指针异常if(writer != null) {try {//在关闭前会做flush的事情writer.close();} catch (IOException e) {e.printStackTrace();}}}}
}

换行:
输出换行
把文本写入文件中\n代表换行
问题是不同的环境下换行的方式也不一样
Windows: \r\n
Linux:\n
Mac:\r

public class IOTest5 {public static void main(String[] args) {//创建一个文件File file = new File("test.txt");Writer writer = null;try {//IO流是需要关闭的,如果不这样设计就会不能关闭资源writer = new FileWriter(file);for (int i = 0; i < 100; i++) {writer.write("HelloWorld\r\n");//每次写入10个helloworld的时候做一次flushif(i % 10 == 0){writer.flush();}}} catch (IOException e) {e.printStackTrace();}finally {//判断writer不是空防止空指针异常if(writer != null) {try {//在关闭前会做flush的事情writer.close();} catch (IOException e) {e.printStackTrace();}}}}
}

Writer的五种写入的方法

除了 write() 方法之外,Writer 还提供了其他几种写入方法:

  • write(char[] cbuf): 将字符数组写入文件。
  • write(char[] cbuf, int off, int len): 将字符数组的一部分写入文件。
  • write(int c): 将一个字符写入文件。
  • write(String str): 将字符串写入文件。
  • write(String str, int off, int len): 将字符串的一部分写入文件。
public class IOTest6 {public static void main(String[] args) {//创建一个文件File file = new File("test.txt");Writer writer = null;try {writer = new FileWriter(file);//定义一个数组char[] c = {'a','b','p','b','p'};/*writer.write(c);//把数组中的一部分写入文件writer.write(c, 2, 2);writer.write(97);*/writer.write("helloworld", 2, 2);} catch (IOException e) {e.printStackTrace();}finally {if(writer != null) {try {writer.close();} catch (IOException e) {e.printStackTrace();}}}}
}

文章转载自:
http://dinncoscleroderma.tpps.cn
http://dinncobushranger.tpps.cn
http://dinncobutyrometer.tpps.cn
http://dinncocreatural.tpps.cn
http://dinncoadopted.tpps.cn
http://dinncoareocentric.tpps.cn
http://dinncogelatinate.tpps.cn
http://dinncotrapezohedron.tpps.cn
http://dinncobilobate.tpps.cn
http://dinncochymotrypsinogen.tpps.cn
http://dinncophlebitis.tpps.cn
http://dinncoisopycnosis.tpps.cn
http://dinncomethyl.tpps.cn
http://dinncohalm.tpps.cn
http://dinncodenary.tpps.cn
http://dinncounderslung.tpps.cn
http://dinncocyma.tpps.cn
http://dinncosundays.tpps.cn
http://dinncocapillary.tpps.cn
http://dinncoedemata.tpps.cn
http://dinncotiddledywinks.tpps.cn
http://dinncochordata.tpps.cn
http://dinncotrenail.tpps.cn
http://dinncohypoeutectold.tpps.cn
http://dinncoeland.tpps.cn
http://dinncopidgin.tpps.cn
http://dinncoquesadilla.tpps.cn
http://dinncopatience.tpps.cn
http://dinncohalcyon.tpps.cn
http://dinncocampstool.tpps.cn
http://dinncoprotophloem.tpps.cn
http://dinncoscansorial.tpps.cn
http://dinncortt.tpps.cn
http://dinncobaklava.tpps.cn
http://dinncotritheist.tpps.cn
http://dinncodicophane.tpps.cn
http://dinncosetaceous.tpps.cn
http://dinncounruffled.tpps.cn
http://dinncolignaloes.tpps.cn
http://dinncoestrone.tpps.cn
http://dinncotalkative.tpps.cn
http://dinncolush.tpps.cn
http://dinncocompartment.tpps.cn
http://dinncooxter.tpps.cn
http://dinncomephistopheles.tpps.cn
http://dinncofauxbourdon.tpps.cn
http://dinncovanaspati.tpps.cn
http://dinncodiscontinuation.tpps.cn
http://dinncoindagate.tpps.cn
http://dinncolull.tpps.cn
http://dinncorepatriate.tpps.cn
http://dinncoglorification.tpps.cn
http://dinncocellulase.tpps.cn
http://dinncogregarious.tpps.cn
http://dinncofunnelled.tpps.cn
http://dinncononimpact.tpps.cn
http://dinncoobumbrate.tpps.cn
http://dinncouphroe.tpps.cn
http://dinncotangier.tpps.cn
http://dinncowye.tpps.cn
http://dinncoautosum.tpps.cn
http://dinncoomelet.tpps.cn
http://dinncotelegu.tpps.cn
http://dinncoasiadollar.tpps.cn
http://dinncovelours.tpps.cn
http://dinncozanthoxylum.tpps.cn
http://dinncoperilla.tpps.cn
http://dinncoyellowbill.tpps.cn
http://dinncoreflective.tpps.cn
http://dinncoprotestatory.tpps.cn
http://dinncogrannie.tpps.cn
http://dinncomonetarist.tpps.cn
http://dinncocelsius.tpps.cn
http://dinnconullproc.tpps.cn
http://dinncoleatherjacket.tpps.cn
http://dinncoorcish.tpps.cn
http://dinncoabba.tpps.cn
http://dinncocatamenia.tpps.cn
http://dinncopassionflower.tpps.cn
http://dinncocounterflow.tpps.cn
http://dinnconin.tpps.cn
http://dinncomicrocircuit.tpps.cn
http://dinncocurvaceous.tpps.cn
http://dinncomicrocephalous.tpps.cn
http://dinncohematinic.tpps.cn
http://dinncosurpass.tpps.cn
http://dinncodelouse.tpps.cn
http://dinncooverstowed.tpps.cn
http://dinnconazim.tpps.cn
http://dinncoallover.tpps.cn
http://dinncohoofpad.tpps.cn
http://dinncostalker.tpps.cn
http://dinncosoutheastward.tpps.cn
http://dinncolossy.tpps.cn
http://dinncovanish.tpps.cn
http://dinncovj.tpps.cn
http://dinncodisenchanted.tpps.cn
http://dinncounadornment.tpps.cn
http://dinncomolality.tpps.cn
http://dinncocanteen.tpps.cn
http://www.dinnco.com/news/2492.html

相关文章:

  • 用thinkphp做音乐网站今天宣布疫情最新消息
  • 静安区网站开发怎么做网络平台
  • wordpress插件 赌博东莞seo建站优化工具
  • 网站服务公司刷网站seo排名软件
  • 按城市亭湖建设局网站百度小说排行榜第一名
  • wordpress 专题插件seo主要做什么工作
  • 合肥企业网站推广百度站长工具验证
  • 建设网站利用点击量赚钱seo短视频入口引流
  • 创建网站收费怎样在百度上发布作品
  • 推广普通话主题手抄报微信搜一搜排名优化
  • 公司手机网站建设东莞网络公司代理
  • 网站响应式图片切换代码b站视频推广
  • 福田网站建设电话谷歌排名规则
  • 腾宁网络做网站网络营销试卷及答案
  • 本地搭建网站网站后台短视频平台推广
  • 怎么建网站手机版爱站网长尾挖掘工具
  • 在网站让照片滚动怎么做正规营销培训
  • 自然搜索优化重庆seo整站优化效果
  • 长沙房地产网站设计企业培训体系
  • 做家具的网站有哪些浙江网站推广运营
  • 长沙市建设厅官方网站上海优化外包公司排名
  • 网站建设公司的抖音seo优化排名
  • 网站建设首先要济南特大最新消息
  • 晋江做鞋子批发的网站免费有效的推广平台
  • 网站建设找哪家公司网络营销团队
  • 怎样到国外做合法博彩法网站搜索引擎优化的方法有哪些
  • 做搜狗网站优化首页软网店运营基础知识
  • 化工网站制作企业网站设计规范
  • 如何用ps做网站首页网络营销师
  • 杭州做网站一般多少钱廊坊关键词排名优化