惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Darknet – Hacking Tools, Hacker News & Cyber Security
Jina AI
Jina AI
博客园_首页
J
Java Code Geeks
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 司徒正美
Hugging Face - Blog
Hugging Face - Blog
S
SegmentFault 最新的问题
MyScale Blog
MyScale Blog
P
Proofpoint News Feed
L
Lohrmann on Cybersecurity
Forbes - Security
Forbes - Security
大猫的无限游戏
大猫的无限游戏
Vercel News
Vercel News
Y
Y Combinator Blog
Google DeepMind News
Google DeepMind News
The Register - Security
The Register - Security
N
News | PayPal Newsroom
S
Security Archives - TechRepublic
量子位
Cisco Talos Blog
Cisco Talos Blog
V
V2EX
C
Cisco Blogs
The Cloudflare Blog
Stack Overflow Blog
Stack Overflow Blog
L
LangChain Blog
Scott Helme
Scott Helme
S
Securelist
Security Latest
Security Latest
爱范儿
爱范儿
TaoSecurity Blog
TaoSecurity Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
I
Intezer
L
LINUX DO - 最新话题
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Check Point Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
美团技术团队
Know Your Adversary
Know Your Adversary
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
PCI Perspectives
PCI Perspectives
月光博客
月光博客
T
Tailwind CSS Blog
Cloudbric
Cloudbric
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
K
Kaspersky official blog
D
DataBreaches.Net
博客园 - 【当耐特】
有赞技术团队
有赞技术团队

博客园 - IT 笔记

Subversion Revert File will not be shown in Modification Surprise vb.net WinForm don't require instance to access the instance value Properties.Settings show error 'System.Windows.Forms.PropertyStore' does not contain a definition for 'Settings' Add Image in MS Report RDLC by using Embedded Image 王爽汇编 Lab 13 Question 1, 用两个程序实现 Spring.NET Installation and setup the first program 王爽汇编语言 实验11 王爽汇编语言 检测点11.2 王爽 汇编语言程序课程设计1 王爽 汇编语言程序设计实验10,题三,数值转换。(Assembly experiment Convert HEX to Decimal and Show on screen ) 王爽 汇编语言程序设计 实验9 (Assembly Language Study) 王爽 汇编语言程序设计 检测点9.1 第2题 The NTVDM CPU has encountered an illegal instruction. CS:0006 IP:130a .... select files by multiple extension name Access Denied when running Spring.IocQuickStart.MovieFinder How to install autotrace in fontforge My first postscript program .net 2 config A generic winform skeleton support interactive UI during large job process
using vb.net read unix style text file
IT 笔记 · 2010-03-22 · via 博客园 - IT 笔记

Unix text file uses linefeed only to indicate end of line, the .net streamreader's readline function is not working with unix text file.

I made a small wrapper for StreamReader class to make it is working with unix format.

At first, I created a class

代码

Imports System.IOPublic Class StreamReaderUnix
    
Inherits streamreader
    
Sub New(ByVal filename As String)
        
MyBase.New(filename)
    
End SubPublic Function ReadLine(ByVal unixStyle As StringAs String
        
Dim intByte As Integer
        
Dim bteRead() As ByteDim mybuffer(1As Char
        
Dim lineFeedLocation As Integer
        
Dim aLine As String = String.Empty If unixStyle = "" Then
            
MyBase.ReadLine()
        
Else 
            
Do While Not intByte = -1
                intByte 
= MyBase.Read(mybuffer, 01)
                
If intByte <> -1 Then
                    lineFeedLocation 
= Array.IndexOf(mybuffer, CChar(vbLf))
                    
If mybuffer(0= CChar(vbLf) Then
                        
Return aLine
                    
ElseIf mybuffer(0= CChar(vbCr) Then
                        
'doing nothing
                    Else
                        aLine 
= aLine & mybuffer(0)
                    
End If
                
End If
            
Loop
        
End If 
    
End Function
End Class

Below is the sample code to use this class

Dim oRead As StreamReaderUnix
oRead 
= New StreamReaderUnix("sample.txt")
Dim lineIn As String
While oRead.Peek <> -1
   lineIn 
= oRead.ReadLine("unix")
   
MsgBox(lineIn)
End While