zoukankan      html  css  js  c++  java
  • Byte|Stream|String测试操作

    static void ByteTest()
    {
    byte[] namebytearray = System.Text.Encoding.UTF8.GetBytes("zzy");
    string readstr = string.Empty;
    Stream mstream = new MemoryStream(namebytearray);//字节数组转换成内存流
    long length = mstream.Length;
    byte[] bufferbyte = new byte[length];
    mstream.Read(bufferbyte, 0, int.Parse(length.ToString()));//流读取到字节数组
    string resultstr = Encoding.UTF8.GetString(bufferbyte);//字节数组转换成字符串
    Console.WriteLine("流转换成字符串:" + resultstr);
    using (StreamReader streamReader = new StreamReader(Environment.CurrentDirectory + "/test.txt"))
    {
    while (!streamReader.EndOfStream)
    {
    readstr += streamReader.ReadLine() + " ";
    }
    }

    Console.WriteLine("从文件读出来的字符串: " + readstr);
    Console.ReadKey();
    }


    -------------------------------------------------- 技术很菜却一直想做大牛!
  • 相关阅读:
    3288 积木大赛
    3284 疯狂的黄大神
    1531 山峰
    1018 单词接龙
    1432 总数统计
    1507 酒厂选址
    1063 合并果子
    几个sort不能过的题目
    poj 2245 Lotto
    求两圆相交面积模板
  • 原文地址:https://www.cnblogs.com/chinaboyzzy/p/4729893.html
Copyright © 2011-2022 走看看