0

I'm developing a java program that will read a file, for example; PSD file (example.psd), and I'll edit the bytes of the file. How can I call the adobe software and have it read the edited bytes through the java program without having to write out the file?

package sandbox;

import java.io.IOException;

public class Sandbox {

    /**
     * Example of how to run an executable from Java.
     * 
     * @param args 
     */
public static String readFileAsString(String fileName)throws Exception 
  { 
    String data = ""; 
    data = new String(Files.readAllBytes(Paths.get(fileName))); 
    return data; 
  } 
    public static void main(String[] args) {
        try {
            Runtime runTime = Runtime.getRuntime();
  String data = readFileAsString("C:\\Users\\pankaj\\Desktop\\example.psd");      
            String executablePath = "C:\\Users\\sdkca\\AppData\\Local\\Programs\\Adobe\\Adobe.exe";

            Process process = runTime.exec(executablePath);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

I can call the adobe, and also read the bytes, how would I tell the adobe to read the bytes?

Hither Joe
  • 117
  • 2
  • 9
  • You would not. And you were able to read the psd file just fine with Java. Of course, Java can't do anything useful with that. Also, a `String` is text (not binary). Sorry. – Elliott Frisch Apr 22 '20 at 15:05
  • Generally, you can't, because the programmer who wrote that Adobe software did not program it to accept an undetermined source of bytes. They wrote it to open a file and read it. So it expects a file on a filesystem. – RealSkeptic Apr 22 '20 at 15:21
  • @RealSkeptic That means it's possible, but the software(Adobe) has to be edited to receive bytes from undetermined source, or marking my java program as determine source. Right? – Hither Joe Apr 22 '20 at 15:30

1 Answers1

0

Take a look here: Java open file with another program

If there is a default opener for the file in the local OS, then that Desktop.getDesktop().open(...)

may do the trick