Home Java Beginners Constructing a File Name path



Constructing a File Name path
Posted on: June 7, 2007 at 12:00 AM
This Java programming tutorial will teach you how you can construct a file name path.

Constructing a File Name path

     

This Java programming tutorial will teach you how you can construct a file name path. By using the constructing filename path it is possible to set dynamic path, which is helpful for mapping local  file name with the actual path of the file. 

Java API has provided us many packages, one of them is java.io  package. This package contains a File class  In this example we are using one static final variable of File class i.e.. separatorChar. The value of this separator is system dependent.  If we are using Windows platform then the value of this separator is  ' \ ' .

The code of the program is given below:

import java.io.*;

public class ConstructingFileNamePath {
  public static void main(String[] args){
    String filepath = File.separatorChar 
"java" + File.separatorChar + "example";
  System.out.println("The path of the file is  :  " + filepath);
     }
}

Output of this program is given below:

C:\java>java ConstructingFileNamePath
The path of the file is : \java\example

Download this example

Related Tags for Constructing a File Name path:
javawindowscapifileideclassormformstaticiovariablewindowsystemcharpackagesvivalueusingriathisidaipackageplatformifforexamplefinaltocontainsexamwseilvarpemaninjava.iormasstamntparseparatorjpackclesemendagepenpircproackdosystorxaxampsatanypackishamplarstattformtfvassrithavstabablatiapalufinmanypleplprndono


Ask Questions?    Discuss: Constructing a File Name path  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.