[英]NSInputStream wrapper to read strings by specified delimiter
I am porting a java client to the iphone and i have been wondering if there is a wrapper around NSInputStream to read strings from a stream stopping at a specified delimiter? 我正在将一个java客户端移植到iphone,我一直想知道NSInputStream是否有一个包装器从一个停止在指定分隔符的流中读取字符串? I am thinking of something like Javas Scanner class (http://download.oracle.com/javase/6/docs/api/index.html?overview-summary.html).
我在考虑像Javas Scanner类(http://download.oracle.com/javase/6/docs/api/index.html?overview-summary.html)。
I need this functionality because my iphone client is recieving messages from the server where the end of a message is defined by the chars CR and LF 我需要此功能,因为我的iphone客户端正在接收来自服务器的消息,其中消息的结尾由字符CR和LF定义
I have been searching google and stackoverflow without any luck. 我一直在搜索谷歌和stackoverflow没有任何运气。 Just asking to make sure i dont start re-inventing the wheel so to speak.
只是要求确保我不会开始重新发明轮子可以这么说。
Thanks for any help! 谢谢你的帮助! :=)
:=)
I don't think that's possible. 我不认为这是可能的。 Maybe you could read the stream to a buffer, convert to NSString and search for your delimiters.
也许您可以将流读取到缓冲区,转换为NSString并搜索您的分隔符。 NSInputStream allows you to read chunks of N bytes but you have to convert it to an NSString on your own and then work on your logic with the delimiters.
NSInputStream允许您读取N个字节的块,但您必须自己将其转换为NSString,然后使用分隔符处理逻辑。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.