Gilad, thank you so much.  I am new to Java and have been researching
pass-by-ref/value topics in Java for the last hour!  Essentially, the
external variable output is a pointer to the same object as the object
outputStream, is that correct?  Thanks again.

On Mon, Dec 29, 2014 at 2:57 PM, Gilad Denneboom <[email protected]>
wrote:

> All of these variables are references to the same object, so when the
> contents of the object are edited inside the writeText function the value
> pointed at by the external variable (*outputStream* in getText) are changed
> as well.
> In other words, when *outputStream *is assigned to *output *(inside
> writeText) all it says is for that variable to point to the same object
> reference. It does not create a copy of the variable under a new name.
>
> On Mon, Dec 29, 2014 at 1:43 PM, A.M. Sabuncu <[email protected]> wrote:
>
> > I am reading the PDFTextStripper.java code and I am stuck trying to
> > understand a mechanism used within the code.
> >
> > Following is the getText() method:
> >
> >     public String getText( PDDocument doc ) throws IOException
> >     {
> >         StringWriter outputStream = new StringWriter();
> >         writeText( doc, outputStream );
> >         return outputStream.toString();
> >     }
> >
> > As you can see, getText() calls writeText() with an outputStream.  In
> > writeText(), the global variable "Writer output" is set to outputStream:
> >
> >     output = outputStream;
> >
> > But there is no code that sets outputStream back to output.
> Nevertheless,
> > outputStream.toString() (in getText) returns the extracted text.
> >
> > I know I am missing something here, and any help will be appreciated.  If
> > you think I should post this to the developers' list, please let me know.
> >
> > Thanks so much.
> >
> > PS: I am using the latest version of PDFBox 1.8.8.
> >
>

Reply via email to