文本文件的处理

来源:互联网 发布:网络机柜厂商 编辑:程序博客网 时间:2024/05/14 02:59

package com.lesson24;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;

public class ByteWriteTest {

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  String str = "adsfasdfas";
  ByteArrayInputStream bin = new ByteArrayInputStream(str.getBytes());
  ByteArrayOutputStream bout = new ByteArrayOutputStream();
  tra(bin, bout);
  System.out.println(new String(bout.toByteArray()));
 }

 // 将一个流转成一个别的流啊
 public static void tra(ByteArrayInputStream bin, ByteArrayOutputStream bout) {
  while (true) {
   int ch = bin.read();
   if (ch == -1) {
    break;
   }
   // 字母小写转成大写的
   int re = Character.toUpperCase(ch);
   bout.write((byte) ch);
  }
 }
}

原创粉丝点击