English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

if u do program using file class for ex c:\java.txt to be created ,when you run this pgm it shows file created manu lly it is not present

2006-07-15 02:00:19 · 3 answers · asked by asraf a 1 in Computers & Internet Programming & Design

3 answers

use this line in your coding

File fil = new File("c:\\java.txt");

dont forget to include the file class.

2006-07-17 23:15:20 · answer #1 · answered by kanna 3 · 0 0

public class Fileextends Objectimplements Serializable, ComparableAn abstract representation of file and directory pathnames.

User interfaces and operating systems use system-dependent pathname strings to name files and directories. This class presents an abstract, system-independent view of hierarchical pathnames. An abstract pathname has two components:

An optional system-dependent prefix string, such as a disk-drive specifier, "/" for the UNIX root directory, or "\\\\" for a Microsoft Windows UNC pathname, and
A sequence of zero or more string names.
Each name in an abstract pathname except for the last denotes a directory; the last name may denote either a directory or a file. The empty abstract pathname has no prefix and an empty name sequence.
The conversion of a pathname string to or from an abstract pathname is inherently system-dependent. When an abstract pathname is converted into a pathname string, each name is separated from the next by a single copy of the default separator character. The default name-separator character is defined by the system property file.separator, and is made available in the public static fields separator and separatorChar of this class. When a pathname string is converted into an abstract pathname, the names within it may be separated by the default name-separator character or by any other name-separator character that is supported by the underlying system.

A pathname, whether abstract or in string form, may be either absolute or relative. An absolute pathname is complete in that no other information is required in order to locate the file that it denotes. A relative pathname, in contrast, must be interpreted in terms of information taken from some other pathname. By default the classes in the java.io package always resolve relative pathnames against the current user directory. This directory is named by the system property user.dir, and is typically the directory in which the Java virtual machine was invoked.

The prefix concept is used to handle root directories on UNIX platforms, and drive specifiers, root directories and UNC pathnames on Microsoft Windows platforms, as follows:

For UNIX platforms, the prefix of an absolute pathname is always "/". Relative pathnames have no prefix. The abstract pathname denoting the root directory has the prefix "/" and an empty name sequence.
For Microsoft Windows platforms, the prefix of a pathname that contains a drive specifier consists of the drive letter followed by ":" and possibly followed by "\\" if the pathname is absolute. The prefix of a UNC pathname is "\\\\"; the hostname and the share name are the first two names in the name sequence. A relative pathname that does not specify a drive has no prefix.
Instances of the File class are immutable;

2006-07-21 08:51:11 · answer #2 · answered by ihoston 3 · 0 0

I am not quite sure what you are asking but I do know that a java file has to have the extension .java and the filename and the class name must be exactly the same. From the cmd prompt type in "javac C:\...\filename.java" to compile and "java C:\...\filename" (w/out .java) to execute.

2006-07-15 09:46:58 · answer #3 · answered by Anonymous · 0 0

fedest.com, questions and answers