首页 > 其他分享 >转化流Demon02

转化流Demon02

时间:2023-04-26 17:56:07浏览次数:31  
标签:fos isr readData 转化 printStackTrace Demon02 catch null

package test2;

import java.io.*;

//转换流
public class Demo03 {
public static void main(String[] args) {

FileOutputStream fos = null;
FileInputStream fis = null;
InputStreamReader isr = null;
try {
fos = new FileOutputStream("H:\\Java2234\\Test.txt");

fos.write("北京".getBytes("GBK"));
fos.write("北京".getBytes("UTF-8"));

fos.flush();

fis = new FileInputStream("H:\\Java2234\\Test.txt");

isr = new InputStreamReader(fis);

int readData;

while ((readData = isr.read()) != -1) {
System.out.println((char)readData);
}

} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (isr != null) {
try {
isr.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}




}
}

标签:fos,isr,readData,转化,printStackTrace,Demon02,catch,null
From: https://www.cnblogs.com/Leizi-go/p/17356858.html

相关文章

  • 10.数制转化
     问题分析: 十进制整数转换为R进制整数的基本方法是:“除R取余”。具体做法为:对于十进制数整数,用R连续除要转换的十进制整数及各次所得之商,直除到商等于0时为止,则各次所得之余数即为所求R进制整数由低位到高位的值。这个过程可以写成一个简单的循环。    一般而言,对于......
  • [oeasy]python0137_相加运算_python之禅_import_this_显式转化
    变量类型相加运算回忆上次内容上次讲了是从键盘输入变量input函数可以有提示字符串需要有具体的变量接收输入的字符串 输入单个变量没有问题但是输入两个变量之后一相加就非常离谱 ​ 添加图片注释,不超过140字(可选)......
  • jsoup将富文本转化为纯文本
    1.添加jar包<dependency><groupId>org.jsoup</groupId><artifactId>jsoup</artifactId><version>1.14.3</version></dependency>2.测试publicstaticvoidmain(S......
  • int数组转化为List
    评:今天想把int数组转换为List,知道在Arrays里有一个静态的方法asList();所以就用了:int[]data=newint[]{1,2,3};ListdataList=Arrays.asList(data);结果运行起来得不到想要的结果,后来看了一下,是因为没有得到想要的List。自己试了试。把int改为Integer就行了:Inte......
  • JavaScript将时间戳转化为时间
    consttimestampToTime=(timestamp)=>{constdate=newDate(timestamp*1000);constyear=date.getFullYear();constmonth=(date.getMonth()+1).toString().padStart(2,'0');constday=date.getDate().toString().padStart(......
  • 二进制转化为十进制
    一、问题描述:输入一个8位二进制数,将其转化为十进制数输出。二、设计思路:输入一个8位二进制数;转换为十进制数,每一位乘以该位的权再相加;输出十进制数。三、流程图四、伪代码实现:a<-0fori<-7to0doa+=2^i五、代码实现:1#include<iostream>2#include<cmat......
  • Java stream实现list转化为map
    在Stream流中将List转换为Map,是使用Collectors.toMap方法来进行转换。key和value都是对象中的某个属性值。Map<String,String>userMap1=userList.stream().collect(Collectors.toMap(User::getId,User::getName));使用箭头函数Map中,key是对象中的某个属性值,value是......
  • C# Byte数组转化String详解(c# byte转化为string)
    C#Byte数组转化String详解(c#byte转化为string)原文链接:https://www.zhiu.cn/148955.htmlC#编程过程中将Byte数组转化String是咱们常常碰到的问题,那么怎么处理C#Byte数组转化String呢?那么咱们来看看详细的涉及到的办法以及关于怎么处理C#Byte数组转化String的评论。FCL得许多......
  • PDF转化为txt文件
    环境python>=3.6包pipinstallpdfminer.six直接贴代码:#!/usr/bin/envpython3.8.6#_*_coding:utf-8_*_#Description:#Author:qiaoxiaohang<[email protected]>#Date:2023/4/1218:20frompdfminer.pdfinterpimportPDFPageInterpreter,PD......
  • 火山引擎数智平台协助洞察美图类 APP 新增长 付费用户转化超过 124%
     更多技术交流、求职机会,欢迎关注字节跳动数据平台微信公众号,回复【1】进入官方交流群美图类APP的下一个增长点在哪里?目前,国内市场上的美图类APP大多都遵循着基础功能免费使用、个性化热门功能收费使用的原则。即用户可以在APP内选择基础的免费修图功能,比如「瘦脸瘦身」、......