title: How to reopen a file from a input stream
body: <p>I want to re-open a file. I have a file in Input stream. I have tried using Scanner and using BufferedReader. But I am unable to open the file again after it is closed using close() method. Please help how to open a file again.
  I have written the below code:</p>
  
  <pre><code>InputStream filename = getAttachstream();
  
          int rows =0 ;
  
          BufferedReader br= new BufferedReader(new InputStreamReader(filename));
          String strLine = "";
            try {
              while( (strLine = br.readLine()) != null) {
                  rows++;
                }
              //br.reset();
              br.close();
              //br.reset();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  if(rows&gt;0){
              InputStream filename1 = getAttachstream();
              Scanner inputStream1 = new Scanner(filename1);
                  for (int rowIncr = 1; inputStream1.hasNext(); rowIncr++) {
  
                  String data;
                  try {
                      data = br.readLine();
                  } catch (IOException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
                  String [] values = data.split(",");
                  String curRowPartNumber = values[0];
                  String curRowQuantity =   values[1];
                  if(rowIncr == 1)
                  {
                      if((values[0]==null || values[0].trim().length()&lt;=0)
                              || (values[1]==null || values[1].trim().length()&lt;=0)
                              || (values[2] != "") || !"Part Number".equalsIgnoreCase(values[0].trim())
                              || !"Quantity".equalsIgnoreCase(values[1].trim())){
                          System.out.println("Invalid Excel sheet data");
                          throw new ECApplicationException(ECMessage._ERR_CMD_INVALID_DATAFORMAT, CLASSNAME,methodName);
                      }
  
                  }
  </code></pre>