"URI is not absolute" exception with correct path

Hello!
I’m trying to create Document from template file and provide to constructor absolute path string:

String path = "/opt/apache-tomcat/bin/C:/Files/filename.docx";
Document document = new Document(path);

But I get “IllegalArgumentException: URI is not absolute”, maybe because this path have Linux and Windows URI attributes simultaneously. If I change path to “/opt/apache-tomcat/bin/C/Files/filename.docx” (without colon and with copying file to new directory) or “C:/Files/filename.docx” (not absolute path!), Document object will be created correctly.
Is it possible to fix absolute path validation, because directory name with colon is correct for linux?

Aspose.Words version: 22.10, OS: Ubuntu 20.04.

@gainetdin As I can see a colon is reserved character almost for all file systems:
https://en.wikipedia.org/wiki/Filename#Comparison_of_filename_limitations

In your case you can simply read the file into the input stream and create a document from stream:

FileInputStream inputStream = new FileInputStream("/opt/apache-tomcat/bin/C:/Files/filename.docx");
Document doc = new Document(inputStream);
1 Like