• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

FileNotFoundException but Why?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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


 
Paul Huestis
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 255
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 255
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because I answered the question in a hurry on a break and neglected to delete the quoted text.
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You still can delete them now. Thanks!
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Click the little icon with a pencil on your own post.
 
Matt Senecal
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I deleted it before you posted this!

Originally posted by Roseanne Zhang:
You still can delete them now. Thanks!


 
And then the entire population worshiped me like unto a god. Well, me and this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic