Skip to main content
Participant
March 16, 2023
Question

how to close a stream created with: stream = util.readFileIntoStream(path of textfile.txt)

  • March 16, 2023
  • 2 replies
  • 810 views

- Acrobat Pro batch JavaScript

- includes the following line:  stream = util.readFileIntoStream(path of textfile.txt)

- runs and completes OK

- if I then try to open textfile.txt with TextPad, I get a sharing violation

- I have to close Acrobat Pro to release the file

Question: how do I close the stream from within the batch script? Tried "stream.close()" but got a "not a function" error.

This topic has been closed for replies.

2 replies

Participant
March 27, 2023

Thanks for the response. No, the Action completes w/o problems before I try to open the text file. Maybe a little more detail may help:

- the text file contains a JSON hiearchy of directories and files that the Action processes

- the Action reads the file with util.readFileIntoStream(), then calls JSON.parse() to initialize the corresponding JS object

After the Action completes, if I try to open the JSON file in TextPad to make a quick manual change, TextPad gives me a sharing violation. I have to close Acrorbat Pro in order to make the change.

try67
Community Expert
Community Expert
March 16, 2023

This shouldn't be necessary. Are you trying to open the file while the Action is running, though? I'm not sure that's a good idea...