zoukankan      html  css  js  c++  java
  • 字符串和Stream 分割

    字符串分割:

    public List<StringBuilder> SplitLength(StringBuilder SourceString, int Length)
            {
                List<StringBuilder> list = new List<StringBuilder>();
                try
                {                
                    Length = Length * 1024 * 1024 * 2;
    
    
                    for (int i = 0; i < SourceString.Length; i += Length)
                    {
                        if ((SourceString.Length - i) >= Length)
                            list.Add(new StringBuilder(SourceString.ToString(i, Length)));
                        else
                            list.Add(new StringBuilder(SourceString.ToString(i, SourceString.Length - i)));
                    }                
                }
                catch (Exception e)
                { }
                return list;
            }

    Stream 分割:

    private static List<byte[]> SplitLength(MemoryStream stream)
            {
                int Length = 2 * 1024 * 1024;
                List<byte[]> bytelist = new List<byte[]>();
                int streamlength = (int)stream.Length;
                stream.Seek(0, SeekOrigin.Begin);
    
                for (int i = 0; i < streamlength; i += Length)
                {
                    if ((streamlength - i) >= Length)
                    {
                        byte[] bt = new byte[Length];
                        stream.Read(bt, 0, Length);
                        bytelist.Add(bt);
                    }
                    else
                    {
                        int lastlen = streamlength - i;
                        byte[] bt = new byte[lastlen];
                        stream.Read(bt, 0, lastlen);
                        bytelist.Add(bt);
                    }
                }
                return bytelist;
            }
  • 相关阅读:
    创建精灵--九宫格
    精灵灰化
    根据点中坐标,调整怪物动作方向
    从tableview中拖动某个精灵
    CCardSlip
    CCImage
    cocos2d-x---CCLabelTTF加载字体库
    CCAction、CCFiniteTimeAction、CCSpeed、CCFollow
    CCObject
    html中charset和content-language的区别
  • 原文地址:https://www.cnblogs.com/lili9696189/p/11314578.html
Copyright © 2011-2022 走看看