Create Text File In Memory?

Is there a way to create a file in memory only that you can write a string to and then destroy it after it’s used? I’m using Windows. Thanks!

Why do you need a file? Why not just have a string property?

It must be a file there is no way to pass a string as a parameter for the program I am using, I already tried that. It only takes a file as a parameter. Thanks.

If i needs a file it probably needs a real file on disk

Create a Temporary File. and then use TextOutputStream to put something in the file on disk. Then pass the Temporary File into your function.

Not entirely in memory but It’ll work I think for my purposes and it destroys itself automatically so that’s a plus. Hopefully the file extension won’t make a difference but I’m guessing this is as close as I am going to get. Thanks!

It does not destroy itself automatically. It will remain in the temporary folder unless you delete it.

Actually, on Windows, it does, on Mac/Linux, it does not. But since it’s inconsistent on Windows, I’d delete it manually too.

This difference, especially the inconsistency, drove me nuts when I was working on Kaju. The original plan called for the updater script to be stored in the temp folder and I couldn’t figure out why it wasn’t running on quit. It took a while to realize that the temp file was being deleted by the system on quit since it wasn’t happening every time.

I would never argue with Tim, he’s helped me out so many times I can’t even count them all. I guess I meant on app close the temp file seems to delete itself on Windows. I’m only working with Windows at the moment so it’s working great for me!

Kem’s right. It does appear to delete itself, as long as the program exists normally. I think my memory was clouded by debugging sessions, where a normal termination is rare.