Click here to Skip to main content
15,886,019 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to open File from File Descriptor?
Posted

I have planed the following thing,please tell me will it possible?
1.Decided to execute lsof command in android program itself for the process
(Android each app is represented by separate process,so i will able to retrieve its process id)
so command will be
>lsof ProcessIDOfApp
output will be table containing FD as well as is name including other information
2.Map the FD to its name
when we get the file name we will able to create the input/output stream.
 
Share this answer
 
v3
Comments
Richard MacCutchan 12-Dec-14 5:27am    
What happens when you try it?
 
Share this answer
 
Comments
Sarita S 10-Dec-14 10:09am    
I have File Descriptor which is integer value.
How Could I Construct the FileDescripter object from it.? or
How Could open File from File descripter.?
Richard MacCutchan 10-Dec-14 10:13am    
See http://docs.oracle.com/javase/7/docs/api/java/io/FileInputStream.html. Information like this is all available in the documentation.
Sarita S 10-Dec-14 10:17am    
Actually FileInputStream require FileDescriptor object to open the input stream.But I don't have FileDescriptor object.I just have File descriptor which is integer value.I tried
FileDescriptor obj=new FileDescriptor(fd);
Here fd is file descriptor containing integer value.
But It did not work.
Richard MacCutchan 10-Dec-14 10:55am    
An integer is not a file descriptor, you need to provide more information. Where does that number come from and what are you trying to do with it?
Sarita S 10-Dec-14 23:10pm    
I need to retrive Input and Output stream of USB device in android.
I tried
int fd = UsbDeviceConnection.getFileDescriptor();
Above statement return file descriptor which is the integer value.
How could I construct FileDescriptor objcet from this integer value?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900