• 字符串和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;
            }
  • 相关阅读:
    matplotlib 画图
    Mac anzhuangxgboost
    scala _ parameter
    cv 验证
    groupie
    pandas map, apply, applymap区别
    画图
    xgboost dmatrix中的 weight的重要性
    自然语言处理的训练范式
    java-处理大容量文本文件,行内分格符为TAB的方法
  • 原文地址:https://www.cnblogs.com/lili9696189/p/11314578.html
Copyright © 2020-2023  润新知