need solution to get file name from path which should give by user

need solution to get file name from path which should give by user

how do i write a program in java that i should get file path from arguments.currently this code creates the file at d:\ but i need to get this file name as a argument how do i do it???am using netbeans for this.

    StringWriter sw = new StringWriter();
    StreamResult result = new StreamResult(sw);
    DOMSource source = new DOMSource(doc);
    transformer.transform(source, result);
    String xmlString = sw.toString();
    File file = new File("d:/Exported.xml");
    BufferedWriter bw = new BufferedWriter
   (new OutputStreamWriter(new FileOutputStream(file)));
   bw.write(xmlString);

 bw.flush();
     bw.close();
View Answers

October 14, 2011 at 4:32 PM

Use file.getName() method of File class.









Related Tutorials/Questions & Answers:
need solution to get file name from path which should give by user
need solution to get file name from path which should give by user  how do i write a program in java that i should get file path from arguments.currently this code creates the file at d:\ but i need to get this file name
which path we have to give in order to upload a file from any where in the system
which path we have to give in order to upload a file from any where... to specifying a path in the code from that path only it is taking image . what i have...; <td><INPUT NAME="file" TYPE="file"></td> </tr> <
Advertisements
Need Solution to get vaues from sql database in java
Need Solution to get vaues from sql database in java  hi I have... file. please provide me solution to get values for xml tags from database... need to get values from sql database for values in the blank field(" "). how do i
Need solution to get values for XML namespace tags from SQL database in Java
Need solution to get values for XML namespace tags from SQL database... comp:loc=" "/> now i need to get values from sql database for values... and created xml tags in separate file. please provide me solution to get values for xml
Java Get File Name
Java Get File Name       In this section, you will study how to obtain the name of file.  In order to get the file name, we have provided the path of file 'Hello.txt
Getting path name of uploading file in struts 2.8.1
Getting path name of uploading file in struts 2.8.1  Hai! I am using struts 2.8.1. I want to upload file into database with the path name. How can I can get the original path name of the file in struts 2.8.1? It only display
executing a batch file which depends on jar files from a system tray but console should not display.
executing a batch file which depends on jar files from a system tray but console should not display.  Hi all, I got following requirement, I have to run a batch file which is depending on some jar files and it displays a frame
Constructing a File Name path
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... Constructing a File Name path   
Getting path name of uploading file in struts 2.1.8
Getting path name of uploading file in struts 2.1.8  In my question I used struts 2.8.1 instead of 2.1.8. Sorry
How to get path of a file in iOS?
How to get path of a file in iOS?  Hi iOS project I have added a file abg.jpg, Now I want to know the path of the image file when installed in iOS. Pl let's know the code. Thanks   Hi, You can use following code
How to give path to the Dfile?
on sphinx, i have to give path to the sphinx4.jar file which is present in my...How to give path to the Dfile?  Hello erveryone, I want to make... not linux ,i want to try above but in this i can't get the write Dfile path , can
Constructing a File Name path in Java
Constructing a File Name path        In Java, it is possible to set dynamic path, which is helpful for mapping local  file name with the actual path of the file using
Storing content from file path to an array
Storing content from file path to an array  Hi, I have a path... would like to access the "Animation.txt" file from this path and store the contents in this text file to an array. I am using jsp. I can access my path but how
Java file get name
Java file get name In this section, you will learn how to get the name... class, you can get the name of any file. Output:ADS_TO_REPLACE_2... called the method getName() through the object of File class which returns
how to find which user has modified the file
how to find which user has modified the file  how to find which user has modified the file
Delete a File
a specified file or directory is deleted. For deleting a file from a directory you need to give the file name to be deleted. Description of program: The following code of program deletes a file from a directory. In this program the compiler
solution to get values for xml namespace tags from sqldatabase in java
solution to get values for xml namespace tags from sqldatabase in java ...=" "/> now i need to get values from sql database for values in the blank... tags in separate file. please provide me solution to get values for xml tags
Want solution to get values for xml namespace tags from database in java
Want solution to get values for xml namespace tags from database in java ...:loc=" "/> now i need to get values from sql database for values in the blank... xml tags in separate file. please provide me solution to get values for xml tags
How to get the browsed file path into controller bean using JSF icefaces
How to get the browsed file path into controller bean using JSF icefaces  Hi All, I've a requirement as, 1) Need to browse a file from my local system/machine 2) Path of the file from which I browsed need to be stored
How to retrieve file name and path of an excel spreadsheet imported into Oracle Database
How to retrieve file name and path of an excel spreadsheet imported into Oracle... Oracle database and I want to know how to retrieve the path of the file... table for each spreadsheet but I want to obtain the path and filename of each
File path for jar file
not found for the template file. Also I had tried to get that path from user...File path for jar file  Hi Experts, I have created one eclipse... path of the template, which is working as per expectation. But I have created
How to create file and save it into user defined path using jsp/servlet?
How to create file and save it into user defined path using jsp/servlet?  Hi.. Onclick event I have created one file.When file will create it should asked where to save file(like browse option
how to show image as a link which path coming from database
how to show image as a link which path coming from database   iam not getting proper answer for it. I am using netbeans .the url coming instring from database ,want to display as image on jsp . please help me
I want to put user guide in pdf and word in side WEB-INF and need to give link on the home page
I want to put user guide in pdf and word in side WEB-INF and need to give link on the home page  I want to put user guide in pdf and word formats... logged in) and need to give link on the home page. These user guide documents url
How to store user name,city,state,image path into database and image into folder using jsp
How to store user name,city,state,image path into database and image into folder using jsp  How to store user name,city,state,image path into database and image into folder using jsp
Read File from specified path in Java
reads a text file from specified path in Java. We will give complete path...How to read a file from a specified path in Java? After learning so many... and interfaces to work with files and directories. If you try to read a file from which
I want to know the given class name exists in which jar file?
I want to know the given class name exists in which jar file?   I want to know the given class name exists in which jar file? C:\Program Files\IBM... the name of the jar file where 'com.rational.ft.util.debug' class exists
How to get full path of the uploaded file using commons fileupload jar file
How to get full path of the uploaded file using commons fileupload jar file  I want to upload file to database with its full path. Because... type.I am in need to get the full path. Can anyone help me to get the full path
java how to get domain name from url
java how to get domain name from url  How to get the domain name from a url string? Example program in java for "how to get domain name from url" Thanks   Hi, You can use the following example code: URL linkURL
how to get selected name from combo box
how to get selected name from combo box   i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my question is that............. i havt to get particular id of worker on selection
how to get selected name from combo box
how to get selected name from combo box   i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my question is that............. i havt to get particular id of worker on selection
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my question is that............. i havt to get particular id of worker on selection
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my question is that............. i havt to get particular id of worker on selection
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my question is that............. i havt to get particular id of worker on selection
How to get the full path location using <input type=file>
How to get the full path location using input type=file  Hi. I have used input type=file> in HTML to select an image. But it selects only the image but not with its full path location. how to do it? Thanks in advance
how to get java path name
Java file absolute path
Java file absolute path In this section, you will learn how to get the absolute path of the file. Description of code: If you want to locate a file without... created an object of File class and passed the name of the file as an argument
No SDK with the name or path
Missing or No SDK with the name or path for XYZ version follow the steps below...No SDK with the name or path  When i run any downloaded application on my mac professional ..it always returns a message no sdk with the name
PHP Get Absolute Path
This example shows you how you can get the absolute path of a file. We... can get the absolute path of the file. ADS_TO_REPLACE_1 Code: <?php//to know your absolute path ADS_TO_REPLACE_2 echo realpath(dirname("
open pdf file in same jsp page and the pdf file should retrieved from database
open pdf file in same jsp page and the pdf file should retrieved from database  Hai all, I need code to open a pdf file in same jsp page(browser) while click on hyperlink And the file was located in database table. Can any
How to get month name from date(like-25/06/2012) using java?
How to get month name from date(like-25/06/2012) using java?  How to get month name from date(like-25/06/2012) using java
need to update key , value pair in map from properties file
need to update key , value pair in map from properties file  I have a map with key , value pair. with key as integer and value as string datatype. I... .properties file where i will update the keys and values whenever needed. i want
find jar file name from multiple set of jar files
find jar file name from multiple set of jar files   I would like to find jar file name from multiple set of jar files where the given class nameââ?¬Â?com.rational.ft.util.debugââ?¬Â
sql query to get name,age,phone,address from tables t1,t2,t3,t4,t5 ..
sql query to get name,age,phone,address from tables t1,t2,t3,t4,t5 ..  ... , address FROM t1 order by name"; this is for 2 tables : query ="SELECT t.name... by name"; i want for 12 tables : i want to fetch name age pwd phone address from 12
Getting the Parents of file name path in Java
Getting the Parents of file name path in Java...() method is the system method which is imported from the System class... will learn how to get the parent directory of the current working directory. Program
Fileupload from source path to destination path
Fileupload from source path to destination path  first we will create one .doc file and .rtf file in one location statically.In html we will give... will give source path as statically where the .doc or .rtf files path will be their.and
Java get byte array from file
Java get byte array from file  what is the code example in Java for getting byte array from file in memory. Thanks   This is very simple... example for Reading file into byte array Reading a File into a Byte Array Thanks
Java Get classes In Package
the classes from the package by providing the path of the jar file and the package name.    ADS_TO_REPLACE_1  The class JarInputStream read... Java Get classes In Package   
ModuleNotFoundError: No module named 'solution-efe-client-user'
ModuleNotFoundError: No module named 'solution-efe-client-user'  Hi...: No module named 'solution-efe-client-user' How to remove the ModuleNotFoundError: No module named 'solution-efe-client-user' error? Thanks  
how to create xls file and give download option using jsp/servlet?
how to create xls file and give download option using jsp/servlet?  Hi, how to create file and give download option to user,so that the user can save the file on defined path

Ads