如何有效地chunk长串 [英] How to efficiently chunk long string

查看:82
本文介绍了如何有效地chunk长串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我正在尝试使用以下代码将长字符串SourceString分块为LineLength




Dim sReturn As String =""

Dim iPos As Integer = 0

Do到iPos> = SourceString.Length - LineLength

sReturn + = SourceString.Substring(iPos,LineLength)+ vbCrLf

iPos + = LineLength

循环

sReturn + = SourceString.Substring(iPos)


如果SourceString小于1 mb,则可以。但如果它超过5 MB,那么时间和机器资源的成本是无法忍受的。

有没有人有更好的想法或处理大型SourceString的例程?

谢谢和问候,

Anony

Hi All,

I''m trying to chunk a long string SourceString into lines of LineLength
using this code:

Dim sReturn As String = ""
Dim iPos As Integer = 0
Do Until iPos >= SourceString.Length - LineLength
sReturn += SourceString.Substring(iPos, LineLength) + vbCrLf
iPos += LineLength
Loop
sReturn += SourceString.Substring(iPos)

It''s OK if the SourceString is less than 1 mb. But if it''s over 5 mb, the
cost of time and machine resource is intolerable.
Does anyone has a better idea or a routine dealing with large SourceString?
Thanks and regards,
Anony

推荐答案

Hi Anony,


为什么要发送真实的language.vb问题还有dotnet.general

组。

language.vb新闻组是你总能获得答案的组合之一。

答案。


您的答案(顺便提一下一般小组的发送),


对于您的问题是字符串制作者

大致写在


我希望它有帮助吗?


Cor

\\ \\

dim sb as System.text.Stringbuilder

Dim iPos as Integer

For i to SourceString.Length - lineLength - 1 ''自己检查一下我没有

检查一下

sb.append(Sour ..... et& vbCrLf)''你能保持这个&安培;那个

内联

next

dim mystring as string = sb.tostring

///
Hi Anony,

Why are you sending a real "language.vb" question also to the dotnet.general
group.
The language.vb newsgroup is one of the groups where you get always an
answer.

Your answer (sended from the general group by the way),

For your problem is the stringbuilder

Roughly written beneath

I hope it helps?

Cor
\\\\
dim sb as System.text.Stringbuilder
Dim iPos as Integer
For i to SourceString.Length - lineLength - 1 ''check this yourself I did not
check it at all
sb.append(Sour..... et & vbCrLf ) ''you can can keep that & that
goes inline
next
dim mystring as string = sb.tostring
///
我正在尝试使用此代码将长字符串SourceString分块为LineLength行:

Dim sReturn As String =""
Dim iPos As Integer = 0
直到iPos> = SourceString.Length - LineLength
sReturn + = SourceString.Substring(iPos,LineLength)+ vbCrLf
iPos + = LineLength <循环
sReturn + = SourceString.Substring(iPos)

如果SourceString小于1 mb就可以了。但如果它超过5 mb,时间和机器资源的成本是无法容忍的。
有没有人有更好的想法或例行处理大的
SourceString?

感谢和问候,
Anony
I''m trying to chunk a long string SourceString into lines of LineLength
using this code:

Dim sReturn As String = ""
Dim iPos As Integer = 0
Do Until iPos >= SourceString.Length - LineLength
sReturn += SourceString.Substring(iPos, LineLength) + vbCrLf
iPos += LineLength
Loop
sReturn += SourceString.Substring(iPos)

It''s OK if the SourceString is less than 1 mb. But if it''s over 5 mb, the
cost of time and machine resource is intolerable.
Does anyone has a better idea or a routine dealing with large SourceString?

Thanks and regards,
Anony



.NET框架语言无关紧要。他遇到的问题和你的答案将与VB.NET,C#,C ++,MSIL或任何其他使用.NET框架的语言相关。他本可以在.NET Framework新闻组中发布这个。
The .NET framework is language indifferent. The problem he is having and your answer would be relevant for VB.NET, C#, C++, MSIL or probably any other language that uses the .NET framework. He could have posted this in the .NET Framework newsgroup also.


实际上它不是真正的language.vb。问题但是.NET框架

问题。处理多语言

框架时,该行变得模糊。我不介意这两个地方的问题。只是我的两分钱......

" Cor Ligthert" <无********** @ planet.nl>在消息中写道

新闻:O%*************** @ TK2MSFTNGP12.phx.gbl ...
Actually its not a real "language.vb" question but a .NET framework
question. The line gets blurred when dealing with a multi-language
framework. I don''t mind the question in both places. Just my two cents...
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:O%***************@TK2MSFTNGP12.phx.gbl...
Hi Anony,

为什么要发送真正的language.vb对
dotnet.general小组也有疑问。
language.vb新闻组是你总能得到答案的小组之一。

你的答案(发送给我们)顺便提一下一般的小组),

对于你的问题是字符串构建者

大致写在

我希望它有帮助吗?

\\\\
dim sb as System.text.Stringbuilder
Dim iPos as Integer
我来源SourceString.Length - lineLength - 1''自己检查一下我做了
完全不检查
sb.append(Sour ..... et& vbCrLf)''你能保持这个&那个
内联
下一个
dim mystring as string = sb.tostring
///
Hi Anony,

Why are you sending a real "language.vb" question also to the dotnet.general group.
The language.vb newsgroup is one of the groups where you get always an
answer.

Your answer (sended from the general group by the way),

For your problem is the stringbuilder

Roughly written beneath

I hope it helps?

Cor
\\\\
dim sb as System.text.Stringbuilder
Dim iPos as Integer
For i to SourceString.Length - lineLength - 1 ''check this yourself I did not check it at all
sb.append(Sour..... et & vbCrLf ) ''you can can keep that & that
goes inline
next
dim mystring as string = sb.tostring
///
我正在尝试大块一个长字符串SourceString成为LineLength的行使用此代码:

Dim sReturn As String =""
Dim iPos As Integer = 0
Do to iPos > = SourceString.Length - LineLength
sReturn + = SourceString.Substring(iPos,LineLength)+ vbCrLf
iPos + = LineLength
循环
sReturn + = SourceString.Substring(iPos )

如果SourceString小于1 mb就可以了。但如果它超过5 mb,
时间和机器资源的成本是无法容忍的。
有没有人有更好的想法或例程处理大型
I''m trying to chunk a long string SourceString into lines of LineLength
using this code:

Dim sReturn As String = ""
Dim iPos As Integer = 0
Do Until iPos >= SourceString.Length - LineLength
sReturn += SourceString.Substring(iPos, LineLength) + vbCrLf
iPos += LineLength
Loop
sReturn += SourceString.Substring(iPos)

It''s OK if the SourceString is less than 1 mb. But if it''s over 5 mb, the cost of time and machine resource is intolerable.
Does anyone has a better idea or a routine dealing with large


SourceString?


SourceString?



感谢和问候,
Anony


Thanks and regards,
Anony




这篇关于如何有效地chunk长串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆