Click here to Skip to main content
16,021,417 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i can list the files in jlist...but cant able to open the file

What I have tried:

Java
JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fc.showOpenDialog(null);
File directory = fc.getSelectedFile();
if ( directory != null && directory.isDirectory()) {
    File[] subFiles = directory.listFiles();
    for ( int i = 0; i < subFiles.length; i++ ){
        listModel.addElement( subFiles[i] );
    }
}
Posted
Updated 17-May-16 5:15am
v3
Comments
Member 12200805 17-May-16 10:55am    
i have found the solution to add the files in jlist...but i cant find the solution to open the file .
Afzaal Ahmad Zeeshan 17-May-16 11:22am    
You don't open the file, you start reading the stream of bytes from it. Java doesn't have a beautiful API as C#.

1 solution

 
Share this answer
 

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