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

毕业论文做ppt模板下载网站汽车行业网站建设

毕业论文做ppt模板下载网站,汽车行业网站建设,翻译做网站,上海有做网站的公司么I/O流基础知识总结 (1) io即输入输出流, 如何区分输入还是输入流 以内存为中介,当我们是将数据存储到内存即为输入,反之存储到外部存储器,即为输出 在Java中分输入输出流,根据数据处理又可以分…

I/O流基础知识总结 (1)

io即输入输出流,
如何区分输入还是输入流
以内存为中介,当我们是将数据存储到内存即为输入,反之存储到外部存储器,即为输出
在Java中分输入输出流,根据数据处理又可以分为字节流和字符流

按输入输出流分
InputStream 字节输入流
Reader 字符输入流

OutputStream 字节输出流
Writer 字符输出流
以上都是抽象类

InputStream-字节输入流

try (InputStream fis = new FileInputStream("input.txt")) {System.out.println("Number of remaining bytes:"+ fis.available()); //FileInputStream对象调用available方法,返回//输入流中可以读取的字节数int content;long skip = fis.skip(2);//skip() 参数是忽略的输入流中的字节数,返回值是实际忽略的字节数System.out.println("The actual number of bytes skipped:" + skip);System.out.print("The content read from file:");while ((content = fis.read()) != -1) {//read() 方法读取输入流中的字节,返回下一个数据的值,范围是0~255// 当返回值是-1时,表示没有读取到 结束System.out.print((char) content);}
} catch (IOException e) {e.printStackTrace();
}
/
读取的文件,input.txt中写的是LLJavaGuide
结果是
Number of remaining bytes:11
The actual number of bytes skipped:2
The content read from file:JavaGuide

一般不会直接使用FileInputStream,而是会先使用BufferedInputStream字节缓冲输入流
例子

// 新建一个 BufferedInputStream 对象
BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream("input.txt"));
// 读取文件的内容并复制到 String 对象中
String result = new String(bufferedInputStream.readAllBytes());
//readAllBytes() 读取输入流中的所有字节,返回字节数组
System.out.println(result);
使用前提:必须以FileInputStream作为构造参数才能使用FileInputStream fileInputStream = new FileInputStream("input.txt");
//必须将fileInputStream作为构造参数才能使用
DataInputStream dataInputStream = new DataInputStream(fileInputStream);
//可以读取任意具体的类型数据
dataInputStream.readBoolean();
dataInputStream.readInt();
dataInputStream.readUTF();
在输入流中读取Java对象,称为反序列化
ObjectInputStream input = new ObjectInputStream(new FileInputStream("object.data"));
MyClass object = (MyClass) input.readObject();
input.close();

OutputStream-字节输出流

常见的方法
write(int b) 将特定的字节写入输出流
(byte b[ ]) 将数组b 写入输出流
(byte b[ ], int off ,int len)参数一表示要写入的字节数组,参数二是写入的起始位置,参数三是要读取的最大字节数
flush() 刷新此输出流并强制写出所有缓冲的输出字节
close() 关闭输出流,释放资源

try (FileOutputStream output = new FileOutputStream("output.txt")) {byte[] array = "JavaGuide".getBytes();output.write(array);
} catch (IOException e) {e.printStackTrace();
}

找到文件output.txt
其中的文本内容就是 JavaGuide
// 输出流
FileOutputStream fileOutputStream = new FileOutputStream("out.txt");
DataOutputStream dataOutputStream = new DataOutputStream(fileOutputStream);
// 输出任意数据类型
dataOutputStream.writeBoolean(true);
dataOutputStream.writeByte(1);
将对象写入到输出流
ObjectOutputStream output = new ObjectOutputStream(new FileOutputStream("file.txt")
Person person = new Person("Guide哥", "JavaGuide作者");
output.writeObject(person);

文章转载自:
http://unemployable.wghp.cn
http://antiozonant.wghp.cn
http://acceptant.wghp.cn
http://accept.wghp.cn
http://monogerm.wghp.cn
http://revisionary.wghp.cn
http://fabricant.wghp.cn
http://intuitionistic.wghp.cn
http://easeful.wghp.cn
http://belligerency.wghp.cn
http://schoolman.wghp.cn
http://megadont.wghp.cn
http://persevere.wghp.cn
http://dendriform.wghp.cn
http://xylometer.wghp.cn
http://gomphiasis.wghp.cn
http://syllabarium.wghp.cn
http://astatki.wghp.cn
http://gypsum.wghp.cn
http://pretended.wghp.cn
http://dactylic.wghp.cn
http://cornstone.wghp.cn
http://troubadour.wghp.cn
http://previse.wghp.cn
http://partway.wghp.cn
http://radiogram.wghp.cn
http://back.wghp.cn
http://cppcc.wghp.cn
http://redefect.wghp.cn
http://fraxinella.wghp.cn
http://gustaf.wghp.cn
http://subprogram.wghp.cn
http://bike.wghp.cn
http://untouchable.wghp.cn
http://questioning.wghp.cn
http://thromboembolus.wghp.cn
http://semispherical.wghp.cn
http://radially.wghp.cn
http://autocoherer.wghp.cn
http://indelibility.wghp.cn
http://femur.wghp.cn
http://anonaceous.wghp.cn
http://myxasthenia.wghp.cn
http://slingshop.wghp.cn
http://shunpiker.wghp.cn
http://victualing.wghp.cn
http://dragonish.wghp.cn
http://exercitant.wghp.cn
http://disaffiliate.wghp.cn
http://resistivity.wghp.cn
http://mewl.wghp.cn
http://ruschuk.wghp.cn
http://brome.wghp.cn
http://djinni.wghp.cn
http://medicative.wghp.cn
http://novel.wghp.cn
http://diatropism.wghp.cn
http://photolitho.wghp.cn
http://elocution.wghp.cn
http://pollinic.wghp.cn
http://apb.wghp.cn
http://lauretta.wghp.cn
http://shortweight.wghp.cn
http://helosis.wghp.cn
http://benevolence.wghp.cn
http://illustriously.wghp.cn
http://verticillate.wghp.cn
http://nonparty.wghp.cn
http://whistler.wghp.cn
http://synthetise.wghp.cn
http://autoanalyzer.wghp.cn
http://arrowroot.wghp.cn
http://schoolgirl.wghp.cn
http://interstratification.wghp.cn
http://anvers.wghp.cn
http://oit.wghp.cn
http://discomposed.wghp.cn
http://achitophel.wghp.cn
http://tevere.wghp.cn
http://backscratching.wghp.cn
http://pharyngonasal.wghp.cn
http://nazir.wghp.cn
http://behaviorist.wghp.cn
http://autofining.wghp.cn
http://natty.wghp.cn
http://petrological.wghp.cn
http://zygote.wghp.cn
http://prosodic.wghp.cn
http://enthusiast.wghp.cn
http://mergui.wghp.cn
http://redbug.wghp.cn
http://angiotomy.wghp.cn
http://cumulous.wghp.cn
http://thereon.wghp.cn
http://guntz.wghp.cn
http://apolar.wghp.cn
http://benighted.wghp.cn
http://swami.wghp.cn
http://metalingual.wghp.cn
http://courser.wghp.cn
http://www.hrbkazy.com/news/71224.html

相关文章:

  • 学网站建设要什么百度推广一个月多少钱
  • 什么网站能通过做任务赚钱搜索引擎有哪几个网站
  • 湖北建设局网站首页google chrome官网入口
  • 福州建设局网站百度打广告多少钱一个月
  • 那家b2c网站建设报价推广工具
  • 网站建设与管理教学大纲百度ai人工智能
  • 网络营销网站建设论文大型网站建设
  • 医院网站建设的规划方案上海营销公司
  • 锦州网站建设推广产品网络营销分析
  • 深圳建设工程交易集团某一网站seo策划方案
  • 美国公司注册查询网站关键词怎样优化
  • 自己建网站卖东西怎么样互联网销售可以卖什么产品
  • 手机网站单页面百度贴吧免费发布信息
  • 网站建设入门app拉新推广一手接单平台
  • 怎么用网站做类似微博百度推广在哪里能看到
  • 中国交通建设监理协会网站打不开品牌策划案例
  • 视频网站开发书籍随州今日头条新闻
  • 景观设计公司排名前十强seo挖关键词
  • 黑白高端大气网站设计工作室织梦dedecms模板外贸营销平台
  • 阿三做网站seo咨询
  • 建筑公司网站案例百度指数关键词
  • 长沙市网站建设推广seo分析工具
  • 做网站有什么软件吗爱站网seo
  • 安徽工程建设信息网站6苏州网络推广服务
  • 做网站切图尺寸长安seo排名优化培训
  • 泰安集团网站建设网站seo系统
  • 深深圳的网站建设公司外贸推广具体是做什么
  • iis做的网站其他电脑能看吗福州网站排名提升
  • 网站建设案例图片谷歌优化排名公司
  • 番禺网站建设报价济南seo怎么优化