0

I use the following method to get all .class files from an eclipse project. but the returned files are in InputStream format which I can not get the content.

public void setFileList(IContainer container) throws CoreException, IOException {
       IResource [] members = container.members();

       for (IResource member : members) {
          if (member instanceof IContainer)  {
              setFileList((IContainer)member);
           } else if (member instanceof IFile && member.isDerived()) {
               IFile file = (IFile)member;

               InputStream contents = file.getContents();
               this.fileList.add(contents);
           }
        }
    }

How can I get the contents of this InputStream in a string format or a txt file?

Däñish Shärmà
  • 2,853
  • 2
  • 24
  • 41

1 Answers1

0

If you want to write it into a file then you can directly use apache.commons.io helper method:

final File outputFile = new File("test.txt");
FileUtils.copyInputStreamToFile(inputStream, outputFile);
Nitin Singhal
  • 453
  • 4
  • 6