opening directory (folder) to reveal contents.
Hi all,
Need help with this issue I've come across. I recently learned how to create a directory. So here the promblem, I created this code for practice to get a better idea of what I can do with a directory. In the code I had a folder created on my desktop and then attempted tp have the directoy open so it would reveal its contents, but its not opening the directory (folder). It will create the folder, but just wont open it. can anyone help and tell me what Im doing wrong?
Code:
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.FileWriter;
/**
*
* @author Solris
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
File data = new File("C:/Users/Solris/Desktop/data");
data.mkdir();
try {
FileWriter d = new FileWriter(data);
} catch (IOException e) {
e.printStackTrace();
}
try
{
BufferedReader r = new BufferedReader(new FileReader("C:/Users/Solris/Desktop/data"));
String content;
while((content = r.readLine()) != null)
{
System.out.println(content);
}
}
catch(Exception ex) {
System.out.println("file read error");
}
}
}