File not found after socket transfer

I have code written to upload a file to the server. the file uploads fine when i dont specify the dir. It uploads to the server current dir, but when i try to upload it to directory "tmp/uniqueDir/filename" that i create in my code i get filnotfound exception. can someone please help me figure out why?

import java.io.BufferedInputStream;

import java.io.BufferedOutputStream;

import java.io.BufferedReader;

import java.io.File;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.InputStreamReader;

import java.net.Socket;

import java.util.Calendar;

import java.util.GregorianCalendar;

/**

*

*/

/**

*

*

*/

publicclass ServerUtil{

String tmpDir;

String fileName;

Process proc;

Runtime runtime = Runtime.getRuntime();

publicstaticfinalint BUFFER_SIZE = 1024 * 50;

privatebyte[] buffer;

/**

*

*/

public ServerUtil(){

// TODO Auto-generated constructor stub

}

publicvoid generateTmpDir(){

java.util.Date d =new java.util.Date();

long off = (long) Math.random();

GregorianCalendar todaysDate=new GregorianCalendar();

int hour,mins,secs;

hour=todaysDate.get(Calendar.HOUR);

mins = todaysDate.get(Calendar.MINUTE);

secs = todaysDate.get(Calendar.SECOND);

String SECS = java.lang.Integer.toString(secs);

String HOUR = java.lang.Integer.toString(hour);

String MINS = java.lang.Integer.toString(mins);

String time = HOUR + MINS + SECS;

/** Unique String Name **/

String RANDOM_OFFSET =new String ();

RANDOM_OFFSET =time + d.hashCode() + RANDOM_OFFSET.hashCode()+ off;

setTmpDir(RANDOM_OFFSET);

try{

proc = runtime.exec("mkdir tmp/" + getTmpDir() );

}catch (IOException e){

// TODO Auto-generated catch block

e.printStackTrace();

}

}

publicvoid uploadFile(Socket socket, BufferedReader rd){

buffer =newbyte[BUFFER_SIZE];

System.out.println("accepted Socket");

try{

BufferedInputStream in =

new BufferedInputStream(socket.getInputStream());

setFileName(rd.readLine());

System.out.println(fileName);

BufferedOutputStream out =

new BufferedOutputStream(new FileOutputStream("tmp/" + getTmpDir() +"/" + getFileName()));

int len = 0;

while ((len = in.read(buffer)) > 0){

out.write(buffer, 0, len);

System.out.print("#");

}

in.close();

out.flush();

out.close();

socket.close();

System.out.println("\nDone!");

}

catch (IOException e){

// TODO Auto-generated catch block

e.printStackTrace();

}

}

/**

* @return the tmpDir

*/

public String getTmpDir(){

return tmpDir;

}

/**

* @param tmpDir the tmpDir to set

*/

publicvoid setTmpDir(String tmpDir){

this.tmpDir = tmpDir;

}

/**

* @return the fileName

*/

public String getFileName(){

return fileName;

}

/**

* @param fileName the fileName to set

*/

publicvoid setFileName(String fileName){

this.fileName = fileName;

}

}

this is the error im getting:

java.io.FileNotFoundException: tmp/0859124333356700/fileName (A file or directory in the path name does not exist.)

at java.io.FileOutputStream.open(Native Method)

at java.io.FileOutputStream.<init>(FileOutputStream.java:201)

at java.io.FileOutputStream.<init>(FileOutputStream.java:153)

at EpkgArchiveServerUtil.uploadFile(ServerUtil.java:93)

at ServerThreads.run(ServerThreads.java:38)

[6571 byte] By [Mjacobsa] at [2007-11-27 8:19:58]
# 1
> java.io.FileNotFoundException:> tmp/0859124333356700/fileName (A file or directory inif tmp/0859124333356700/ does not exist then your file will not be created
tjacobs01a at 2007-7-12 20:08:14 > top of Java-index,Java Essentials,Java Programming...
# 2

"A file or directory in the path name does not exist."

Seems pretty clear to me. What don't you understand about it?

Do you understand about relative versus absolute paths? Do you know that you have to create a directory before you can use it? Did you look on your server to see whether that directory exists?

DrClapa at 2007-7-12 20:08:14 > top of Java-index,Java Essentials,Java Programming...
# 3
The code writes it right before it starts sending the file. So it does exist
Mjacobsa at 2007-7-12 20:08:14 > top of Java-index,Java Essentials,Java Programming...
# 4

You mean this code?proc = runtime.exec("mkdir tmp/" + getTmpDir() );

Does it run with the same working directory as your Java code? And why don't you wait until it finishes? And more to the point, why don't you just use the java.io.File method that will make a directory for you instead of doing a clumsy thing like that?

DrClapa at 2007-7-12 20:08:14 > top of Java-index,Java Essentials,Java Programming...
# 5
Thanks a lot Dr. Clap... I dont know why I was using runtime.exec() i guess because i had to use it earlier and just kept using it...but it was because i was waiting on it to finish. So I just used the java.io.File to make the directory and it works GREAT...THANKS!!!
Mjacobsa at 2007-7-12 20:08:14 > top of Java-index,Java Essentials,Java Programming...