# String as IO?

**URL:** <https://discourse.julialang.org/t/string-as-io/1488>\
**Category:** General Usage\
**Tags:** question\
**Created:** [January 14, 2017, 10:32pm UTC](https://discourse.julialang.org/t/string-as-io/1488 "2017-01-14T22:32:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![trans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/trans/32/345_2.png) [@trans](https://discourse.julialang.org/u/trans)\
**Post date:** [January 14, 2017, 10:32pm UTC](https://discourse.julialang.org/t/string-as-io/1488/1 "2017-01-14T22:32:42Z")

</div>

If I have a string, how can I treat it like an IO? I have a method that takes an IO and I want to pass a string to it, if at the very least for testing.

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [January 14, 2017, 10:37pm UTC](https://discourse.julialang.org/t/string-as-io/1488/2 "2017-01-14T22:37:08Z")

</div>

Try the `IOBuffer()` function. It should do exactly what you need.

---

<div class="post-metadata">

**Author:** ![trans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/trans/32/345_2.png) [@trans](https://discourse.julialang.org/u/trans)\
**Post date:** [January 15, 2017, 12:44am UTC](https://discourse.julialang.org/t/string-as-io/1488/3 "2017-01-15T00:44:53Z")

</div>

That’s the ticket. Thanks!

---

<div class="post-metadata">

**Author:** ![nalimilan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nalimilan/32/147_2.png) [@nalimilan](https://discourse.julialang.org/u/nalimilan)\
**Post date:** [January 16, 2017, 10:02pm UTC](https://discourse.julialang.org/t/string-as-io/1488/4 "2017-01-16T22:02:21Z")

</div>

@trans Please mark the reply as solving the problem next time, it’s useful for people to know whether a question still needs an answer. Thanks!

---

<div class="post-metadata">

**Author:** ![trans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/trans/32/345_2.png) [@trans](https://discourse.julialang.org/u/trans)\
**Post date:** [January 17, 2017, 2:18am UTC](https://discourse.julialang.org/t/string-as-io/1488/5 "2017-01-17T02:18:10Z")

</div>

Didn’t know about that. Okay.
