I was thinking something like a
File file =new File(inputStream) // not possible though. file.canWrite
,
but i cant seem to find a solution to conv
You seem to have it backwards.
By definition, an InputStream
will only ever allow you to read a stream of bytes, wherever that stream of bytes comes from. It may be from a file, or a network socket, or a custom provider. By its very definition, you can only read from an InputStream
anyway.
Since you seem to be working with files here, you can check whether a file is read only for the user running the current process using:
final Path path = Paths.get("path/to/my/file");
// is it writable? If no, consider "read only"
final boolean canWrite = Files.isWritable(path);
And to open an InputStream
from a Path
, use:
try (
final InputStream in = Files.newInputStream(path);
) {
// work with "in"
}