1

I am trying to read file from a mount point in the server where I am deploying the java code. Part of the java code is as below:

public static String encodeFileToBase64Binary(String fileName) throws IOException {

        File file = new File(fileName);

        byte[] bytes = loadFile(file);
        byte[] encoded = Base64.encodeBase64(bytes);
        String encodedString = new String(encoded);

        return encodedString;
    }

But it is throwing ERROR:

Callout to java method "public static java.lang.String encodebase64.EncodeBase64.encodeFileToBase64Binary(java.lang.String) throws java.io.IOException" resulted in exception: /data1/Test_Folder/EmailAttachment/AttachmentOSBTest.txt (No such file or directory) java.io.FileNotFoundException: /data1/Test_Folder/EmailAttachment/AttachmentOSBTest.txt (No such file or directory)

I tried placing the file in {$user.home} in the server and then reading from that path and it is working. Reading from Mount point in server is failing. What extra should I specify in the code?

SharletteMA
  • 85
  • 1
  • 3
  • 13
  • Obviously, `/data1/Test_Folder/EmailAttachment/AttachmentOSBTest.txt` does not exist - did you check if that file is accessible in a shell? – Gyro Gearless Jan 15 '19 at 09:41
  • File path does exist and it is accessible. 'home' and 'data1' directories are at the same level. I am using Jdeveloper tool . When I use file adapter in the tool with the path /data1/Test_Folder/EmailAttachment/AttachmentOSBTest.txt specified, File is read successfully. I am unable to read through Java code. – SharletteMA Jan 15 '19 at 09:48
  • When i changed the java code with absolute path as : File path = new File(file.getAbsolutePath()) it is working perfectly well – SharletteMA Jan 16 '19 at 05:39

0 Answers0