# Read a file separated by blank lines?

**URL:** https://discourse.julialang.org/t/read-a-file-separated-by-blank-lines/69430
**Category:** General Usage
**Tags:** parsing, io
**Created:** [October 8, 2021, 12:59pm UTC](https://discourse.julialang.org/t/read-a-file-separated-by-blank-lines/69430 "2021-10-08T12:59:41Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [October 8, 2021, 2:53pm UTC](https://discourse.julialang.org/t/read-a-file-separated-by-blank-lines/69430/5 "2021-10-08T14:53:14Z")

</div>

> [@greatpet](#):
>
> is it possible to convert `Vector{Char}` to `String` without copying the data and allocating memory, similar to how `take!` constructs `Vector{Char}` without copying?

`String(take!(buf))` already constructs the string without making a copy — from a `Vector{UInt}` in the [UTF-8 encoding](http://utf8everywhere.org/), _not_ a `Vector{Char}`.

(`Vector{Char}` requires 4 bytes per character, similar to UTF-32, which is different from the encoding used by `String`, and is _not_ generally a recommended way to store strings.)

More generally, it _is_ possible to construct a `String(vec)` from a `vec::Vector{UInt8}` without making a copy of `vec`, but only if the `Vector{UInt8}` is specially allocated — this special allocation is done by `IOBuffer` objects and also by `read(io, numbytes)` as documented in the `String` docstring, but can also be accomplished using the undocumented `vec = Base.StringVector(numbytes)` constructor. See also [Document/export copy-free string allocation? · Issue #19945 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/19945) and [Conversion of Vector{UInt8} to String without copy](https://discourse.julialang.org/t/conversion-of-vector-uint8-to-string-without-copy/49837)

You can also use [StringViews.jl](https://github.com/JuliaStrings/StringViews.jl) to create a `String`-like object (another subtype of `AbstractString`) from an `AbstractVector{UInt8}` (e.g. a subarray) without making a copy.

---

_[View the full topic](https://discourse.julialang.org/t/read-a-file-separated-by-blank-lines/69430)._
