# How to Get Content from PDF file placed in Shared path to stream into Pega

**URL:** <https://forums.pega.com/t/how-to-get-content-from-pdf-file-placed-in-shared-path-to-stream-into-pega/1980>\
**Category:** General\
**Tags:** 8-3-1, healthcare-and-life-sciences, data-management\
**Created:** [December 10, 2021, 3:17am UTC](https://forums.pega.com/t/how-to-get-content-from-pdf-file-placed-in-shared-path-to-stream-into-pega/1980 "2021-12-10T03:17:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Haripriya\_Gajarla](https://avatars.discourse-cdn.com/v4/letter/h/898d66/32.png) [@Haripriya\_Gajarla](https://forums.pega.com/u/Haripriya_Gajarla)\
**Post date:** [December 10, 2021, 3:17am UTC](https://forums.pega.com/t/how-to-get-content-from-pdf-file-placed-in-shared-path-to-stream-into-pega/1980/1 "2021-12-10T03:17:14Z")

</div>

Hi,

We are trying with this code for Streaming into the browser. But its not working.

String filePath = tools.getParamValue(“FilePath”);

java.io.FileInputStream fileInputStream=null;

java.io.File file = new java.io.File(filePath);

byte bFile = new byte[(int) file.length()];

try {

fileInputStream = new java.io.FileInputStream(file);

fileInputStream.read(bFile);

fileInputStream.close();

}

catch(Exception e){

e.printStackTrace();

}

/\* Change the name of the Test.docx to the actual file name that needs to be downloaded with extension.\*/

String sErrorMessage = tools.sendFile(bFile, “Test.pdf”, false, null, false);

if (sErrorMessage != null){

tools.getThread().getThreadPage().putString(“pyXMLStream”, sErrorMessage);

}

---

<div class="post-metadata">

**Author:** ![Haripriya\_Gajarla](https://avatars.discourse-cdn.com/v4/letter/h/898d66/32.png) [@Haripriya\_Gajarla](https://forums.pega.com/u/Haripriya_Gajarla)\
**Post date:** [December 27, 2021, 7:02pm UTC](https://forums.pega.com/t/how-to-get-content-from-pdf-file-placed-in-shared-path-to-stream-into-pega/1980/2 "2021-12-27T19:02:12Z")

</div>

Pega wont allow the external shared path, until its mounted.

We have used below code to achieve this functionality

String filePath = tools.getParamValue(“FilePath”);  
String fileName = tools.getParamValue(“FileName”);

java.io.FileInputStream fileInputStream=null;

java.io.File file = new java.io.File(filePath);

byte bFile = new byte[(int) file.length()];

try{  
java.io.FileInputStream fis = new java.io.FileInputStream(file);  
fis.read(bFile);  
fis.close();

}

catch(Exception e){

e.printStackTrace();

}

/\* Change the name of the Test.docx to the actual file name that needs to be downloaded with extension.\*/

String sErrorMessage = tools.sendFile(bFile, fileName, false, null, false);

if (sErrorMessage != null){

tools.getThread().getThreadPage().putString(“pyXMLStream”, sErrorMessage);

}
