当前位置:网站首页>IO之Reader案例
IO之Reader案例
2022-06-22 11:11:00 【ITzhongzi】
核心代码
package ioDemo;
import java.io.*;
import java.nio.charset.Charset;
/** * outputStreamWriter 可以将输出的字节流转换成字符流输出 * InputStreamReader 可以将输入的字节流转换成字符流 */
public class ChangeStreamDemo {
public static void main(String[] args) {
try {
// InputStream is = new FileInputStream("C:\\Users\\lihw\\Desktop\\test\\123.txt");
// read(is);
OutputStream os = new FileOutputStream("C:\\Users\\lihw\\Desktop\\test\\123.txt");
writeDemo(os);
} catch (Exception e) {
e.printStackTrace();
}
}
public static void read(InputStream in) {
try {
Reader reader = new InputStreamReader(in, Charset.defaultCharset());
char[] chars = new char[1024];
int len = -1;
while ((len = reader.read(chars)) != -1) {
System.out.println(new String(chars, 0, len));
}
System.out.println("读取完毕");
reader.close();
}catch (Exception e) {
e.printStackTrace();
}
}
public static void writeDemo(OutputStream out) {
try {
Writer writer = new OutputStreamWriter(out);
writer.write("开开心心来玩耍");
writer.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
边栏推荐
- The R language dplyr package mutate function divides two numeric variables in the dataframe to create a new data column (create a new variable)
- R语言epiDisplay包的idr.display函数获取泊松回归poisson模型的汇总统计信息(初始事件密度比IDR值、调整事件密度比IDR值及其置信区间、Wald检验的p值和似然比检验的p值)
- R language uses read Table load the data set (CSV data) of conditional logistic regression analysis, and use the unique function to view the number of groups of paired data
- 2022年度敏捷教练行业现状报告(2022 State of Agile Coaching Report)
- The R language uses the matchit package for propensity matching analysis and match The data function constructs the matched sample set, and uses visual analysis to test the balance of all covariates i
- Popular understanding of TCP 3-time handshake
- R语言使用read.table加载条件logistic回归分析的数据集(csv数据)、使用unique函数查看配对数据有多少组
- 鉴权之cookie、session、JWT
- Pytoch realizes wave impedance inversion
- Idr Display function obtains the summary statistical information of Poisson regression Poisson model (initial event density ratio IDR value, adjusted event density ratio IDR value and its confidence i
猜你喜欢

The father of the college entrance examination student told himself at night that what he cared about most was not the child's performance, and the turning point was not false at all

The software used is PHP MySQL database

electron添加SQLite數據庫

Development technology of NFT trading platform digital collection system

Security risks exist in open source code: an average of 49 vulnerabilities exist in a project

Pytoch realizes wave impedance inversion

高考生父亲深夜自述,最在意的不是孩子成绩,转折点一点都不假

How many of the eight classic MySQL errors did you encounter?
![[shell] collection of common instructions](/img/27/cba1d42cf8d69a712e2440a82a9ff9.png)
[shell] collection of common instructions

IDE 的主题应该用亮色还是暗色?终极答案来了!
随机推荐
SAVE: 软件分析验证和测试平台
promise升级版async,await来袭,搭配try+catch更香哦
The R language uses the matchit package for propensity matching analysis and match The data function constructs the matched sample set, and uses visual analysis to test the balance of all covariates i
开源代码存在安全隐患:一个项目平均有49个漏洞
Flink状态管理
Cookies and sessions for answers to common interview questions
R语言基于with函数对指定的协变量执行双样本t检验、t.test函数对不同分组对应的协变量的均值进行Welch双样本t检验分析、双独立样本t检验
迪利克雷前缀和学习笔记
R language uses GLM function to build Poisson log linear regression model, processes three-dimensional contingency table data to build saturation model, and uses summary function to obtain model summa
Typical life cycle model of information system project
6-10 全局状态管理 - 全局store
CVPR 2022 oral | a new motion oriented point cloud single target tracking paradigm
rtklib postpos 梳理(以单点定位为例)
【软工】计划和项目管理
Two ways of traversing binary tree: preorder, inorder and postorder
两两交换链表中的节点[单向链表不断链原则]
云端极简部署Svelte3聊天室
如果你是个半路出家的程序员,请一字一句的看完
图片是是用啥解析的dn的binlog的tso,直接用mysqlbinlog好像没有?
Getting to know elastricearch