# Writing Feeder value to a file

**URL:** <https://community.gatling.io/t/writing-feeder-value-to-a-file/2978>\
**Category:** Gatling (Open-Source)\
**Created:** [May 5, 2016, 9:57pm UTC](https://community.gatling.io/t/writing-feeder-value-to-a-file/2978 "2016-05-05T21:57:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saritha\_Reddy](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@Saritha\_Reddy](https://community.gatling.io/u/Saritha_Reddy)\
**Post date:** [May 5, 2016, 9:57pm UTC](https://community.gatling.io/t/writing-feeder-value-to-a-file/2978/1 "2016-05-05T21:57:30Z")

</div>

I have a scenario, something like this:

1. Create user using id generated from Feeder, it’s a Dynamic Feeder
2. Do some stuff
3. Search other users by Ids. Ids is a type of list

I’m having trouble with implementing the step 3.

Since the Id are dynamically generated, I need a way to capture these Ids somewhere , may be to a file and use them in Step 3. I could n’t figure out how to write Ids generated by Feeder into a File.

Tried the following, but could not get this working. ${userId} is not evaluated correctly at the writer.println, the same when used in http get call it’s being evaluated properly. Any thoughts?

val writer = {

val fos = new java.io.FileOutputStream(“data/test-data.txt”)

new java.io.PrintWriter(fos,true)

}

…

.exec(session =\> {

writer.println(“userId :” + “${userId}” )

session

}

---

<div class="post-metadata">

**Author:** ![Saritha\_Reddy](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@Saritha\_Reddy](https://community.gatling.io/u/Saritha_Reddy)\
**Post date:** [May 5, 2016, 10:02pm UTC](https://community.gatling.io/t/writing-feeder-value-to-a-file/2978/2 "2016-05-05T22:02:53Z")

</div>



---

<div class="post-metadata">

**Author:** ![Srinivas\_D](https://avatars.discourse-cdn.com/v4/letter/s/e79b87/32.png) [@Srinivas\_D](https://community.gatling.io/u/Srinivas_D)\
**Post date:** [October 14, 2016, 2:06pm UTC](https://community.gatling.io/t/writing-feeder-value-to-a-file/2978/3 "2016-10-14T14:06:07Z")

</div>

Hi,

I have the exact same problem. Could you please say if you could solve the issue somehow? highly appreciated…

Srinivas

---

<div class="post-metadata">

**Author:** ![Barry\_Perez](https://avatars.discourse-cdn.com/v4/letter/b/7ba0ec/32.png) [@Barry\_Perez](https://community.gatling.io/u/Barry_Perez)\
**Post date:** [October 16, 2016, 1:42pm UTC](https://community.gatling.io/t/writing-feeder-value-to-a-file/2978/4 "2016-10-16T13:42:52Z")

</div>

.exec(session =\> {

val userId = session(“userId”).as[String]

writer.println(“userId :” + userId )

session

}
