Java Reference
In-Depth Information
package
package com . darwinsys . lang ;
import
import java.io.File
java.io.File ;
/** Some things that are System Dependent.
* All methods are static.
* @author Ian Darwin
*/
public
public class
class SysDep
SysDep {
final
final static
static String UNIX_NULL_DEV = "/dev/null" ;
final
final static
static String WINDOWS_NULL_DEV = "NUL:" ;
final
final static
static String FAKE_NULL_DEV = "jnk" ;
/** Return the name of the "Null Device" on platforms which support it,
* or "jnk" (to create an obviously well-named temp file) otherwise.
*/
public
public static
static String getDevNull () {
iif ( new
new File ( UNIX_NULL_DEV ). exists ()) {
return
return UNIX_NULL_DEV ;
}
String sys = System . getProperty ( "os.name" );
iif ( sys == null
null ) {
return
return FAKE_NULL_DEV ;
}
iif ( sys . startsWith ( "Windows" )) {
return
return WINDOWS_NULL_DEV ;
}
return
return FAKE_NULL_DEV ;
}
}
If /dev/null exists, use it.
If not, ask System.properties if it knows the OS name.
No pe, so give up, return jnk .
W e know it's Microsoft Windows, so use NUL: .
 
 
 
 
 
Search WWH ::




Custom Search