# File read String error

**URL:** <https://discourse.julialang.org/t/file-read-string-error/23318>\
**Category:** General Usage\
**Created:** [April 19, 2019, 6:01pm UTC](https://discourse.julialang.org/t/file-read-string-error/23318 "2019-04-19T18:01:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stuart\_Rogers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stuart_rogers/32/10694_2.png) [@Stuart\_Rogers](https://discourse.julialang.org/u/Stuart_Rogers)\
**Post date:** [April 19, 2019, 6:01pm UTC](https://discourse.julialang.org/t/file-read-string-error/23318/1 "2019-04-19T18:01:54Z")

</div>

I am getting the following error when I try to open and read in the contents of a text file as a String. I use Julia 0.6.4 on macOS.

str = open(“ps\_4916\_p8.txt”) do file  
read(file,String)  
end  
ERROR: MethodError: Cannot `convert` an object of type Type{String} to an object of type Array{UInt8,1}  
This may have arisen from a call to the constructor Array{UInt8,1}(…),  
since type constructors fall back to convert methods.  
Stacktrace:  
[1] read(::IOStream, ::Type{T} where T) at ./io.jl:528  
[2] open(::##3#4, ::String) at ./iostream.jl:152

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [April 19, 2019, 6:17pm UTC](https://discourse.julialang.org/t/file-read-string-error/23318/2 "2019-04-19T18:17:16Z")

</div>

> [@Stuart\_Rogers](#):
>
> `read(file,String)`

got added in julia 0.7 if I remember correctly. 0.6.4 is a very old Julia versions, if at all possible, I would strongly recommend to go to 1.1.

---

<div class="post-metadata">

**Author:** ![Stuart\_Rogers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stuart_rogers/32/10694_2.png) [@Stuart\_Rogers](https://discourse.julialang.org/u/Stuart_Rogers)\
**Post date:** [April 19, 2019, 8:23pm UTC](https://discourse.julialang.org/t/file-read-string-error/23318/3 "2019-04-19T20:23:08Z")

</div>

Is there a work-around for Julia 0.6.4?

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [April 19, 2019, 8:25pm UTC](https://discourse.julialang.org/t/file-read-string-error/23318/4 "2019-04-19T20:25:29Z")

</div>

Use the old name for that functionality: [`readstring`](https://docs.julialang.org/en/v0.6/stdlib/io-network/#Base.readstring) (note I’m linking to the 0.6 docs).
