This topic has been archived. It cannot be replied.
-
工作学习 / 学科技术讨论 / generate file under other directory without changing source codeWe have a standalone java app that creates a new file without specifying the absolutely path, which means it is doing something like new File("output.txt"). That by default create output.txt under the directory where the app is launched. However, I would like to change it's behavior so that the output.txt will be generated under other directory and I can't change source code. How can I do it? thanks.
-tongcd(MockingBird);
2008-6-24
{407}
(#4520574@0)
-
bump
-tongcd(MockingBird);
2008-6-25
(#4521620@0)
-
if the program doesn't have a configuration file that allows you change the path..you can't..
-sunday8(sunday8);
2008-6-25
(#4521734@0)
-
1. can't you move the java app to a the other folder? 2.you can have a application "watching" the output file, once it's created, then immediately create a soft link on the other folder?
-holdon(again);
2008-6-25
(#4521973@0)
-
To answer your question1. Sure i can move app to other folder, however, i would like to have one single directory that has no code but this output file along with other generated data. The problem is how to separate the output.txt with application code files.
2. that could be a solution, and can even simply move the output.txt to other directory. However, the effort may not be justified.
thanks
-tongcd(MockingBird);
2008-6-25
{378}
(#4522537@0)
-
if it is running on unix like platform. just run "rm -r -f output.txt && ls -s output.txt /newdirectory/newoutputfile". everytime before u start this java app.if it is on wintel, just create a shortcut.
-buma(蔓毒黛扬);
2008-6-25
{43}
(#4522011@0)
-
this is a interesting point. I am using java and app could run on both unix and windows. Not sure how to programatically create a shortcut in windows.
-tongcd(MockingBird);
2008-6-25
(#4522544@0)
-
能否做一个batch file copy呢?
-canadiantire(轮胎 - Bona fide Crm);
2008-6-25
(#4522013@0)
-
this is what i was thinking too. Though i was hoping to overwrite some sort of system properties to allow the default file being redirected to other folder...
-tongcd(MockingBird);
2008-6-25
(#4522554@0)
-
I am back to answer my own question, find the text from webThe working directory associated with a Java runtime can be retrieved at run time via the system property user.dir (that is, System.getProperty("user.dir")). At run time, file operations are performed relative to the working directory when absolute paths are not specified. When launching a Java program from the command line, the working directory is initialized to the location in the file system from which the VM is launched.
-tongcd(MockingBird);
2008-6-25
{431}
(#4522616@0)