wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes formatting output incorrectly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "formatting output incorrectly" Watch "formatting output incorrectly" New topic
Author

formatting output incorrectly

kevin schmidt
Ranch Hand

Joined: Aug 24, 2001
Posts: 85
Hi,
I'm trying to output directories, subdirectories, and the files contained within. Now I'm doing something wrong. Instead of outputting the file name, I'm getting this:
[Ljava.io.File;@38dj3m5
What am I doing wrong? TIA.
kevin
Rikard Qvarforth
Ranch Hand

Joined: Jul 10, 2001
Posts: 107
Hi if i got the question right ..i think you are caling the toString() function and it is printing the class name and the object name, see the File api for more info ex. getName(),
list().. etc
Hope it helps
Rille

kevin schmidt
Ranch Hand

Joined: Aug 24, 2001
Posts: 85
right now I'm using .listFiles() method... I've tried .list() and .getName... but it doesn't work.
Rikard Qvarforth
Ranch Hand

Joined: Jul 10, 2001
Posts: 107
Thats strange humm. i tried this and this works fine
public static void main(String [] args){
File f = new File("c:\\");
String[] s = f.list();
for(int i =0; i < s.length; i++)
{
System.out.println(s[i]);
}
}

humm well try something this simple and see if it works ..
[This message has been edited by Rikard Qvarforth (edited November 09, 2001).]
[This message has been edited by Rikard Qvarforth (edited November 09, 2001).]
Rikard Qvarforth
Ranch Hand

Joined: Jul 10, 2001
Posts: 107

ps. humm the <s.length did not worked but >< s.length worked
when submiting the message
kevin schmidt
Ranch Hand

Joined: Aug 24, 2001
Posts: 85
What I am doing is taking a directory, listing the directory name, the files inside that directory, then recursively going into a subdirectory if there is, and doing the same, list the the directory name and the files within it. The example you have done, I've done that before, and that works for me, but I want the Directory name as well.
[This message has been edited by kevin schmidt (edited November 09, 2001).]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: formatting output incorrectly