File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes String[ ] to File[ ] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String[ ] to File[ ]" Watch "String[ ] to File[ ]" New topic
Author

String[ ] to File[ ]

Anupam Bhatt
Ranch Hand

Joined: Mar 12, 2004
Posts: 81
Hi,
I have a doubt. Can String array be casted to a File Object array?
It seems to be okay, but just wanna confirm this as the code where i have implemented this can not be build and executed now to check this.
The string array contains the abolute paths to files.
Any comments on this will be appreciated,
Thanks.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18978
    
  40

Originally posted by Anupam Bhatt:
Hi,
I have a doubt. Can String array be casted to a File Object array?
It seems to be okay, but just wanna confirm this as the code where i have implemented this can not be build and executed now to check this.
The string array contains the abolute paths to files.
Any comments on this will be appreciated,
Thanks.


A String object can *not* be casted to a File object.

A String array object can *not* be casted to a File array object.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Anupam Bhatt
Ranch Hand

Joined: Mar 12, 2004
Posts: 81
Henry, Thanks for this.
So now my problem is i have a array of strings[which contains absolute paths to file], but i want to return a array of file objects.

What can be the best possible approach to this ?

Thanks
Shyam Prasad Murarka
Ranch Hand

Joined: May 02, 2005
Posts: 209
Dear Anupam,
I have no idea if this is the best way to do it. But, here's what I suggest:


With Best Regards,
Shyam Prasad Murarka
Anupam Bhatt
Ranch Hand

Joined: Mar 12, 2004
Posts: 81
Shyam,
Thats what exactly what i thought the solution and did. And your reply confirms the same .
Thanks,


Originally posted by Shyam Murarka:
Dear Anupam,
I have no idea if this is the best way to do it. But, here's what I suggest:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String[ ] to File[ ]