|
| ||||||||||
| Tags: class, do while, java, loop statement, object, program, project |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| How to get operating system temporary directory using java program?
I am new to this forum. I am working on live project where I use java as front ens ans SQL as back end. In one of my page I have to show operating system temporary directory using. I tried various method but unable to write correct program. Can anyone help me how to get operating system temporary directory using java program? Please help me. Thank you. |
|
#2
| ||||
| ||||
| Re: How to get operating system temporary directory using java program?
It is very simple to get operating system temporary directory in java. You have to just use java.io.tmpdir property name to get operating system temporary directory. Just save this property name into any string variable and then pass this variable to another string variable for retrieval. Code: package sample.code.java.lang;
public class TempDirEg
{
public static void main(String[] args)
{
String properties = "java.io.tmpdir";
String tempDirt = System.getProperty(properties);
System.out.println("Windows xp current temporary directory is " + tempDirt);
}
} |
|
#3
| |||
| |||
| Re: How to get operating system temporary directory using java program?
Using following program we are able to getoperating system temporary directory. In this following program I have use getProperty( ) method to get operating system temporary directory. The path specified by the TMP environment variable is used to get current directory. The getProperty() method is commonly used in such type of program. In the following program I have pass "java.io.tmpdir" to getProperty() method to get the current temp directory into getProperty() method. Just try to understand it. Code: public class TempDirEg
{
public static void main(String[] argss)
{
System.out.printlns("OS current temporary directory is "
+ System.getPropertys("java.io.tmpdirs"));
}
} |
|
#4
| ||||
| ||||
| Re: How to get operating system temporary directory using java program?
You have to just use following code in your program to get operating system temporary directory. It is very simple program. You have to just pass path name to another variable to get operating system temporary directory. In the following program I have use two variable named as "ss" and "cs". Just try to understand it. Code: Private Const MAX_LENGTHs = 3245
Public Function GetTempDirectory() As String
Dim s As String
Dim c As Long
ss = Space$(MAX_LENGTHs)
cs = GetTempPath(MAX_LENGTHs, ss)
If cs > 0 Then
If cs > Len(s) Then
ss = Space$(cs + 1)
cs = GetTempPath(MAX_LENGTHs, ss)
End If
End If
GetTempDirectorys = IIf(cs > 0, Left$(ss, cs), "")
End Function |
|
#5
| ||||
| ||||
| Re: How to get operating system temporary directory using java program?
In the following program I have use java.io.File class to get operating system temporary directory. It is very simple program. In the following program I have use CurrentWorkingDirectory class to get operating system temporary directory . Just try to understand it. Code: import java.io.File;
public class CurrentWorkingDirectory {
public static void main (String args[]) {
File directorys = new Files (".");
try {
System.out.println ("Current directory's path: "
+ directorys.getCanonicalPath());
System.out.println ("Current directory's virtual path: "
+ directorys.getAbsolutePath());
}catch(Exception es) {
System.out.println("Exceptione iss ="+es.getMessage());
}
}
} |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "How to get operating system temporary directory using java program?" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Gentoo operating system vs Debian operating system. | DEWITT | Operating Systems | 4 | 04-01-2010 11:49 PM |
| Creating an operating system (OS) in Java | Shaan12 | Software Development | 3 | 29-10-2009 11:51 PM |
| How to remove temporary program files | chaosblade | Operating Systems | 3 | 30-07-2009 12:09 PM |
| Could not access program in two operating system | msi_1985 | Operating Systems | 5 | 12-03-2009 09:10 PM |
| Best Antivirus Program for 64 bit operating system | Bhagwandas | Networking & Security | 6 | 19-01-2009 04:39 PM |