Results 1 to 8 of 8
Thread: file path
- 10-27-2008, 05:03 PM #1
Member
- Join Date
- Oct 2008
- Posts
- 4
- Rep Power
- 0
file path
Hello all, Im very very new in java and need a help please.
I have a makefile in the unix system that doing many functions and one of them, creating a file.txt.I want to create a code in the java file that can copy the full path of that file that will created.
so for example.
when creating test.txt so the code will print out the path of that test.txt file
am I explaind good?:(
thank you
- 10-27-2008, 06:40 PM #2
The File class has several methods that return different paths to a file.
I'm not sure what you are asking.
Is the java program to create the file instead of makefile? How will the java program get the path to where it should create the file?
If the java program is NOT creating the file, is it supposed to search for where the file was created? How will it get the name of the file to search for? What if 2 files with the same name?
- 10-28-2008, 08:54 AM #3
Member
- Join Date
- Oct 2008
- Posts
- 4
- Rep Power
- 0
thank for your replay, there are only one file with that name, I mean that, when the makefile executing, in that moment execute the java file for search that file.sorry for my bad explain.
- 10-28-2008, 09:20 AM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Ok, did you read the Java doc for File class. You can find lots of useful ways to do this.
Java 2 Platform SE v1.3.1: Class File
- 10-28-2008, 01:53 PM #5
To search a folder and sub folders you'll also need the File list() method.execute the java file for search
- 10-28-2008, 01:59 PM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Do you want to create a file through the application and find the complete file path? Better to explain it more if I'm wrong.
- 10-29-2008, 02:40 PM #7
Member
- Join Date
- Oct 2008
- Posts
- 4
- Rep Power
- 0
you are right Eranga:) I want to create a file through the application and find the complete file path
- 10-30-2008, 05:39 AM #8
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
So in simple way, why don't you do this.
Make sure that drive C have a folder name Temp. Because in this way you cannot create folders.Java Code:File file = new File("C:\\Temp\\Temp.txt"); try { if(!file.exists()) file.createNewFile(); } catch(IOException ex) { } System.out.println(file.getAbsolutePath());
Can you show your complete code.
Similar Threads
-
Load class file which resides in local path c:\
By praveen.kb in forum Advanced JavaReplies: 2Last Post: 08-12-2008, 01:55 PM -
Specify path
By borgrodrick in forum EclipseReplies: 1Last Post: 02-12-2008, 11:03 PM -
Regular expression for file path
By ravian in forum New To JavaReplies: 3Last Post: 01-25-2008, 08:24 PM -
to find the workspace path at runtime to write the file
By Gnanam in forum Advanced JavaReplies: 5Last Post: 07-31-2007, 04:22 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks