I have created a VFS using JIMFS.
FileSystem virtualFS = Jimfs.newFileSystem(Configuration.unix());
Path virtualPath = virtualFS.getPath("resources/virtualFolder");
Files.createDirectories(virtualPath);
Path refData = virtualPath.resolve("refData.csv");
System.out.println(refData);
Files.write(refData, ImmutableList.of(sData),StandardCharsets.UTF_8);
I am trying to read the file (refData.csv) in another method (Path is passed to the other method).
What I have tried until now are :
1: new FileDataModel(new FileInputStream(Files.lines(refData)));
2: new FileDataModel((File) Files.lines(refData));
3: new FileDataModel(new File(refData));
Unfortunately, none of these work as of now. I understand, I am mixing the default FS with the Virtual FS.
Error: Exception in thread "main" java.lang.UnsupportedOperationException
How to access the file created?.
File
andFileInputStream
just don't work for anything but the default file system. What you'd need is a version ofFileDataModel
's constructor that takes aPath
or a normalInputStream
(you can get anInputStream
for aPath
usingFiles.newInputStream(Path)
).(By the way,
Files.lines
returns aStream
, not aFile
, so I'm not sure what you're trying to do there.)