title: java.nio.file.InvalidPathException: Illegal char <:> at index 4: http:\182.18.177.27:78\PrepaidEMFiles\invoice12.pdf
body: <p>while sending the email with the attachment, i am getting the subjected error.  it is working fine with local system file location(eg. C://PrepaidEMFiles//invoice123.pdf) but when i am using (<a href="http://182.18.177.27:78/PrepaidEMFiles/invoice1547033786877.pdf" rel="nofollow noreferrer">http://182.18.177.27:78/PrepaidEMFiles/invoice1547033786877.pdf</a>) location i am getting the error.below is my code.</p>
  
  <pre><code>try{
   `enter code here`....
  
    String samplePdf = 
    "http://182.18.177.27:78/PrepaidEMFiles/invoice1547033786877.pdf";
  
     FileSystemResource file = new FileSystemResource(samplePdf); 
     helper.addAttachment(file.getFilename(), file);
  
    } catch (MessagingException e) {
     LOGGER.error("Exception in sending mail", e);
     exceptionHandlerDao.exceptionHandlineCode(e, "SENDING EMAIL FOR " + 
     inventoryName + " FOR RECHARGE A DEVICE", "");
     }
  
      sender.send(message);
      }
  </code></pre>
  
  <p>I have tried with varies way to ignore "\" like( </p>
  
  <pre><code>eg.http:\\\\182.18.177.27:78\\PrepaidEMFiles\\invoice1547033786877.pdf) but still getting the same error.Could someone please help me with that error.
  </code></pre>
  
  <p>thanks in advance!!</p>
  
  <p>i have tried various ways to get the file with URL url = inputstream example. but i am getting the binary file as a attachment.Still no use.</p>
  
  <p>Complete error: 
            java.nio.file.InvalidPathException: Illegal char &lt;:> at index 4: </p>
  
  <pre><code>      http:\182.18.177.27:78\PrepaidEMFiles\invoice1547033786877.pdf
       at 
         sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
         at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
        at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
        at sun.nio.fs.WindowsPath.parse(WindowsPath.java:94)
        at sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:255)
        at java.io.File.toPath(File.java:2234)
        at org.springframework.core.io.FileSystemResource.&lt;init&gt; 
       (FileSystemResource.java:82)
       at
  </code></pre>
  
  <p>I need that remotely located pdf file to send it to email attachment.</p>