File read String error

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
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.
[1] read(::IOStream, ::Type{T} where T) at ./io.jl:528
[2] open(::##3#4, ::String) at ./iostream.jl:152

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.

Is there a work-around for Julia 0.6.4?

Use the old name for that functionality: readstring (note I’m linking to the 0.6 docs).

1 Like