3-30java的日子

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.Arrays;


public class Testchar {


public static void main(String[] args) throws IOException {
byte[] b = new byte[] { -50, -46 };
char c = '0';
String s = "我愿意今生唯一zhiyouni";
File file = new File("D://io//file.txt");
FileWriter raf = new FileWriter(file, true); // 带参数true从文件尾开始写,不带参数默认从头开始写
raf.write(s);// 写字符串
raf.write(c);//
raf.write((char) b[1]);//
raf.write(Arrays.toString(b));//
raf.write(new String(b));//
raf.flush();
raf.close();


System.out.println(Arrays.toString(s.getBytes()));// 字符串》字节数组》字符显示,显示为字符串s对应的每个字符(汉字2字节,英文1字节)的ASIC码
System.out.println(Arrays.toString(b));
System.out.println(new String(b));
System.out.println((char) b[1]);
System.out.println(b);


}


}



package IO;



import java.io.IOException;
import java.util.Arrays;


public class IoTest {


public static void main(String[] args) throws IOException {
int a = 1;
String s = new String("123牛振兴");
byte[] b = s.getBytes();
char[] c = s.toCharArray();
byte bb = b[0];
char cc = c[0];
System.out.println("a :"+a);
System.out.println("b :"+b);
System.out.println("c :"+c);
System.out.println("b.toString() :"+b.toString());
System.out.println("c.toString() :"+c.toString());
System.out.println("Arrays.toString(b) :"+Arrays.toString(b));
System.out.println("Arrays.toString(c) :"+Arrays.toString(c));
System.out.println("new String(s.getBytes()) :"+new String(s.getBytes()));
System.out.println("new String(s.toCharArray()) :"+new String(s.toCharArray()));
System.out.println("s :"+s);
System.out.println("bb :"+bb);
System.out.println("cc :"+cc);// out流继承自Printstream的方法
System.out.println(System.in);


System.out.write(a); System.out.println();
System.out.write(b); System.out.println();
// System.out.write(c);//out流继承自Printstream和FilterOutputStream方法
// System.out.write(s);
System.out.write(bb); System.out.println();
System.out.write(cc); System.out.println();
// System.out.write(System.in);


}


}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值