> On Feb 19, 12:44 pm, w...@iprimus.com.au wrote:
>
[quoted text clipped - 13 lines]
> or get a j2me book
> j2me = java 2 mobile edition
Without desiring to start a debate (as my posts sometimes do) I think
that "write once run anywhere" is not 100% accurate. A better wording
should be "write once *correctly*, run anywhere". For example, in the
past couple of weeks, there was a rather interesting discussion thread
in c.l.j.h which talked about the difference in the way newline
characters were coded in Java. As it turns out, different operating
systems handle this differently. Andrew Thompson pointed out
System.getProperty( "line.separator" );
*Here is the actual link: http://shorterlink.com/?WUMPTW*
which is something that I didn't know about.
So, a java program coded on Windows with the windows system of dealing
with newlines will crap out on Linux or other platforms which deal with
it differently unless it is coded correctly by consulting the
System.getProperty method. For a newbie like me, this was a very
important thing to realize. If one is to write code that is truly
portable, one must never assume that something is handled the same way
on all platforms, and code to handle different operating systems, if the
code is going to be used on multiple platforms.
JMTC
John - 20 Feb 2007 01:08 GMT
>> On Feb 19, 12:44 pm, w...@iprimus.com.au wrote:
>>
[quoted text clipped - 38 lines]
>
> JMTC
Stupid asterisks....
http://shorterlink.com/?WUMPTW
Arne Vajhøj - 20 Feb 2007 01:43 GMT
> Without desiring to start a debate (as my posts sometimes do) I think
> that "write once run anywhere" is not 100% accurate. A better wording
[quoted text clipped - 18 lines]
> on all platforms, and code to handle different operating systems, if the
> code is going to be used on multiple platforms.
It may have been news to you, but I do not think it is possible to
create a language with practical enough to be used for real world
programming which prevents programmers of writing non portable code.
If you can specify a filename you can use platform specific syntax
for that. The only thing a language can do is to give the programmer
the necessary tools to write platform independent code.
Arne
PS: System.getProperty( "line.separator" ) should not be used much -
normally you would choose IO classes with builtin line support
for reading or writing files with line structure.
John T - 20 Feb 2007 16:37 GMT
> It may have been news to you, but I do not think it is possible to
> create a language with practical enough to be used for real world
> programming which prevents programmers of writing non portable code.
Not sure what you are saying here...
Heres' an idea... what if the JVM were intelligent enough to take a command,
like say
String a = new String();
a="nnn";
a=a+os.NEW_LINE_CHARACTER;
and automatically convert the NEW_LINE_CHARACTER into the appropriate code
for the OS on which the JVM is running.
> PS: System.getProperty( "line.separator" ) should not be used much -
> normally you would choose IO classes with builtin line support
> for reading or writing files with line structure.
I've never actually used this myself, I was just quoting what someone else
said :-)
Arne Vajhøj - 21 Feb 2007 03:21 GMT
> Heres' an idea... what if the JVM were intelligent enough to take a command,
> like say
>
> String a = new String();
> a="nnn";
String a = "nnn";
would look much better.
> a=a+os.NEW_LINE_CHARACTER;
>
> and automatically convert the NEW_LINE_CHARACTER into the appropriate code
> for the OS on which the JVM is running.
It could.
Do you really think that:
a = a + os.NEW_LINE_CHARACTER;
is so much nicer than:
a = a + System.getProperty("line.separator");
?
Arne