0

hi i have a FileInputStream which is pointing remote file in the server.

how to know the filename and its extension which is pointed by this stream.

if i want to write the remote file in my local computer, i have to know the file name and its extension that's what i want to know

  • what do you actually need , i mean list of present files? – bananas May 28 '16 at 07:14
  • 3
    This http://stackoverflow.com/questions/4930111/get-file-name-from-fileoutputstream ? i.e. you can only try to use reflection, but you're better off changing the way your code works, so that it can get the filename from the proper place. – zapl May 28 '16 at 07:18

2 Answers2

0

There are no public methods that return the File, Path or String from FileInputStream.

The best workaround is to wrap FileInputStream, store File in the wrapper class and implement getFile() method.

Sergei Rybalkin
  • 3,337
  • 1
  • 14
  • 27
-1

try this:

if(file.isDirectory())
       {
           File f=file.listFiles();
            for(File name : f)
                pirnt(name.getName());

}     
bananas
  • 1,176
  • 2
  • 19
  • 39