I liked Pascal's mention of the streams involved. I'm guessing from your requirement for a File object you are calling a method that expects a file:
Could you change the method to want an inputstream argument?
This kind of thinking comes up all the time in "test first development" where you write
JUnit tests before you write the code. It's dead simple for a
unit test to create an input stream froma string, just as you wanted to do, but a real hassle to create a disk file, run the test and erase the disk file.