Solved

Correct Path not being Passed

Posted on 2006-11-10
8
144 Views
Last Modified: 2010-03-31
I am trying to copy a file from one location to another but my file path seems to be getting "changed" on the way.

I start off with: ThreadProcessFiles processThread = new ThreadProcessFiles(new File(fileList[0]).getAbsolutePath());

But the output in the called class looks like: C:\Documents and Settings\username\workspace\ProjectTestImage-001.tif

Which property should I be passing to have the correct link to the file in the Windows platform?

0
Comment
Question by:lasutton
  • 4
  • 2
  • 2
8 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 17916635
>>But the output in the called class looks like: C:\Documents and Settings\username\workspace\ProjectTestImage-001.tif

What is wrong with that and why?
0
 

Author Comment

by:lasutton
ID: 17916648
The actual location of the original file is C:\Input\TestImage-001.gif.

0
 

Author Comment

by:lasutton
ID: 17917204
My problem was as follows:

When using a ".list" of a directory, the string does not contain the path of the files created.  As the path returns a "null" value the .get..Path.. values return the directory of the running application.  

So the directory name needs to be prefixed to the file name found.

                  File foundFile = new File(directoryToMonitor + File.separatorChar + fileList[0] );
0
 
LVL 92

Expert Comment

by:objects
ID: 17918058
>                File foundFile = new File(directoryToMonitor + File.separatorChar + fileList[0] );

could also be done using:

File dir = new File(directoryToMonitor);

               File foundFile = new File(dir, fileList[0] );
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 17918848
>>the .get..Path.. values return the directory of the running application.  

You'll find it's not that directory but the one from where it's being run
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17930211
:-)
0
 
LVL 92

Expert Comment

by:objects
ID: 17936733
> You'll find it's not that directory but the one from where it's being run

the directory of the running appication *is* the directory where it is being run from :-D
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17936744
?
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
changePi Challenge 15 76
How Complex Is This Java Course ? 9 63
Free Alternative to JIRA 4 58
Java - Why doesn't this JFrame work 3 18
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now