Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes FileNotFoundException but Why? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "FileNotFoundException but Why?" Watch "FileNotFoundException but Why?" New topic
Author

FileNotFoundException but Why?

Paul Huestis
Greenhorn

Joined: Oct 01, 2001
Posts: 2
Hi,
I written a Java appl that submits a DOS *.bat to perform an FTP function.
Inside the *.bat I perform a "change directory" and also redirect the output of a dir/ls to file on my side of the FTP transfer. I want to use the dir/ls file to see if the FTP transfer file made it.
The problem arises when I try to read the dir/ls back into the Java appl. I fully qualified the file but still receive - java.io.FileNotFoundException: C:\FILEA.DIR (The system cannot find the file specified)
Any help is greatly appreciated
Matt Senecal
Ranch Hand

Joined: Dec 01, 2000
Posts: 255
Could you post some code? Also, have you verified that the file is actually being written, and that it's being written where you're looking for it?
Originally posted by Paul Huestis:
Hi,
I written a Java appl that submits a DOS *.bat to perform an FTP function.
Inside the *.bat I perform a "change directory" and also redirect the output of a dir/ls to file on my side of the FTP transfer. I want to use the dir/ls file to see if the FTP transfer file made it.
The problem arises when I try to read the dir/ls back into the Java appl. I fully qualified the file but still receive - java.io.FileNotFoundException: C:\FILEA.DIR (The system cannot find the file specified)
Any help is greatly appreciated


There's nothing more dangerous than a resourceful idiot. ---Dilbert
Paul Huestis
Greenhorn

Joined: Oct 01, 2001
Posts: 2
I have verified that the file exists and has data. The following is code

// Start the FTP Transfer by launching the DOS Copy Job
Runtime strtJob = Runtime.getRuntime();
pftp_JobCommand1 = "cmd /c start " + pftp_StartFile;
Process proc1 = strtJob.exec(pftp_JobCommand1);
try {
proc1.waitFor();
proc1.destroy();
}
catch (InterruptedException ex) {
ex.printStackTrace ();
};
// Begin the verfication
try {
// Check the "ConfirmFile" for Sendfile entry
// pftp_ConfirmFile = C:\FILEA.DIR
File pftp_DirectConfirm = new File(pftp_ConfirmFile);

BufferedReader in = new BufferedReader(
new FileReader(pftp_DirectConfirm));
while ((pftp_ConfirmFileRecord = in.readLine()) !=null) {
StringTokenizer parser = new StringTokenizer
(pftp_ConfirmFileRecord,"/");
while (parser.hasMoreTokens()) {
aparser = parser.nextToken();
if (aparser.equals(pftp_Sendfile)) {
System.out.println("Found File : " +
pftp_Sendfile);
pftp_FindFlag = "Y";
};
};
};

DOS being executed
C:
CD
CD C:\TEST\
IF EXIST C:\TEST\FILEA.TXT goto Nextstep
COPY E:\FTPArch\Outbound\FILEA.TXT C:\TEST\FILEA.TXT
:Nextstep
FTP -s:FTPCommands.txt
FTP Script being executed
open USCSTMQEDI1
ftp_user
mqedi
pwd
put \TEST\FILEA.TXT
ls / C:\FILEA.DIR
quit
del C:\TEST\FILEA.TXT
:End
exit

Actual Output
=============
ls / C:\FILEA.DIR
quit
java.io.FileNotFoundException:C:\FILEA.DIR
(The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileReader.<init>(Unknown Source)
at
PerformFTPTransferProcess.pftpStart(PerformFTPTransferProcess.java:173)
at ProcessOutboundFTP.main(ProcessOutboundFTP.java:913)

The BufferedReader is where the error occurs.
Thanks.
Matt Senecal
Ranch Hand

Joined: Dec 01, 2000
Posts: 255
The only thing I can think of is to change "C:\FILEA.DIR" to "C:\\FILEA.DIR"

[This message has been edited by Matt Senecal (edited October 01, 2001).]
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
Sorry! I never understand the mentality of copying someone's post which is just above the copy. I think this is only wasting Paul/JavaRanch's disk space. But for what??
[This message has been edited by Roseanne Zhang (edited October 01, 2001).]
Matt Senecal
Ranch Hand

Joined: Dec 01, 2000
Posts: 255
Because I answered the question in a hurry on a break and neglected to delete the quoted text.
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
You still can delete them now. Thanks!
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
Click the little icon with a pencil on your own post.
Matt Senecal
Ranch Hand

Joined: Dec 01, 2000
Posts: 255
I deleted it before you posted this!
Originally posted by Roseanne Zhang:
You still can delete them now. Thanks!

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: FileNotFoundException but Why?
 
Similar Threads
FTP
keep cmd window open after System.exit(0) (.bat file)
java 1.4 and java 1.5
how to search for a certain extension within a folder
simple FTP from a java-program