ByteArray应用
来源:互联网 发布:网络黄金未来城 编辑:程序博客网 时间:2024/05/21 06:37
package com.phone.week4.day5;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Scanner;
public class TestByteArray {
public static void main(String[] args) throws IOException { //接收你的所在地 //请输入您的所在地 //通过内存流读进来,再通过内存流打印出去 Scanner in = new Scanner(System.in); System.out.println("请输入您的地址:"); String address = in.next(); ByteArrayInputStream bis = new ByteArrayInputStream(address.getBytes()); byte[] b = new byte[bis.available()]; bis.read(b); //读完了 ByteArrayOutputStream bos = new ByteArrayOutputStream(); bos.write(b); System.out.println(bos); if(null!=bos){ bos.close(); } if(null!=bis){ bis.close(); }}private static void test1() throws IOException { //创建一个内存输入流 ByteArrayInputStream bis = new ByteArrayInputStream("暴雨加台风".getBytes()); //System.out.println(bis.available()); //创建一个内存输出流 ByteArrayOutputStream bos = new ByteArrayOutputStream(); byte[] by = new byte[bis.available()]; bis.read(by); //读进来了 bos.write(by); System.out.println(bos); if(bos!=null){ bos.close(); //关闭流 } if(bis!=null){ bis.close(); //关闭流 }}
}
0 0
- ByteArray应用
- ByteArray
- ByteArray(摘)
- ByteArray 写入
- ByteArray 学习
- ByteArray 读
- bytearray-string
- AS3 ByteArray
- ByteArray类,实现Flash的ByteArray方法
- AS3 String to ByteArray,ByteArray to String
- 用ByteArray Clone Array
- ByteArray各方法详解
- ByteArray各方法详解
- ByteArray类介绍
- bitmapData和bytearray互转
- ByteArray生成图片
- ByteArray 和 String 互转
- ByteArray的API
- java的苦恼
- HDOJ 4274 Spy's Work DFS
- POJ 1704 Georgia and Bob
- struts2-ajax-树状数据的输出
- hello world !
- ByteArray应用
- HDU 1281
- 学籍管理系统1——mantis
- Oracle学习笔记20150907索引
- QSettings
- 总理之言
- jQuery实现文本域提示文字点击后消失
- 在线考试系统——测试计划——testlink
- 【C语言】-变量之间的类型转换