Always got 403 response when try to read pdf document using BufferedInputStream

Hello all, i have a problem here
When i try to read pdf document where it placed on server who requires header authentication it always return 403

this is my code :

URL TestURL = new URL(PDFURL);

BufferedInputStream bis = new BufferedInputStream(TestURL.openStream()); → (script stop here)

try this way :
PDFURL = ‘https://username:password@site.com

but it’s not working, anyone have solution please answer my question.
Thank You