Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
83 views
in Technique[技术] by (71.8m points)

How to write a string at the end of the exe file in Java

I am writing a Java code where i have the user id with me which will be needed in the EXE file. So for this I am thinking of appending the user id at the end of the EXE file. The code i have written is as

public void appendUser()
 throws Exception {
 Files.copy("/tmp/generic/myFile.exe", "/tmp/myFile.exe");
 BufferedWriter fileWriter = new BufferedWriter(
 new FileWriter(destination.getFileName().toString()));
 fileWriter.append("[email protected]");
 file = new File(destination.getFileName().toString());
 }

But this will modify the generic copy of the EXE.

I can copy the file at the temp location first and then append the userId on that file and return it. But i want to know if there is any other smart way where i dont have the create the separate copy of the file first .

question from:https://stackoverflow.com/questions/65893562/how-to-write-a-string-at-the-end-of-the-exe-file-in-java

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you can pass the parameters to the executable file instead you could start it directly from the location without copying.
Java Programming: call an exe from Java and passing parameters
But I dont knwo if that's possible for your problem...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...