How to convert FileInputStream to InputStream?

ranjan picture ranjan · Jun 19, 2012 · Viewed 291.4k times · Source

I just want to convert a FileInputStream to an InputStream, how can I do that?

e.g

FileInputStream fis = new FileInputStream("c://filename");
InputStream is = ?; 
fis.close();

Answer

Kumar Vivek Mitra picture Kumar Vivek Mitra · Jun 19, 2012
InputStream is;

try {
    is = new FileInputStream("c://filename");

    is.close(); 
} catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

return is;