Re: Complete command arguments
- From: Lion-O <nosp@xxxxxxxxxxxxxx>
- Date: Sat, 19 Jul 2008 09:22:48 -0500
[short]
Is it possible, in a Java program, to get the complete command
string that was used to start that program?
Thats really quite easy, a mere "enhanced for loop" does the job quite nicely:
public static void main(String[] args) {
StringBuffer arguments = new StringBuffer();
for (String a : args) {
arguments.append(a + " ");
}
}
The only possible downside to this idea is the space at the end, but thats
something a mere trim() can fix.
..in response to the user configuring certain aspects of the program that
are difficult to clean up and re-initialise. So.. if there was some other
way to get a Java program to restart itself, that would do too (though my
searching so far suggests there isn't[?]).
Depending on the context I can't help wonder if you should check if your design
could use adjusting. It sounds a bit odd that the only way to accomplish new
settings is to start the entire program like this. But thats hard to comment on
considering the fact that this heavily depends on context.
--
..\\ PGP/GPG key: http://www.catslair.org/pubkey.asc
.
- Follow-Ups:
- Re: Complete command arguments
- From: Lew
- Re: Complete command arguments
- References:
- Complete command arguments
- From: MRe
- Complete command arguments
- Prev by Date: Re: charset problem with simple chat program
- Next by Date: Re: Complete command arguments
- Previous by thread: Re: Complete command arguments
- Next by thread: Re: Complete command arguments
- Index(es):
Relevant Pages
|
|