Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

formatting output incorrectly

 
kevin schmidt
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
right now I'm using .listFiles() method... I've tried .list() and .getName... but it doesn't work.
 
Rikard Qvarforth
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

ps. humm the <s.length did not worked but >< s.length worked
when submiting the message
 
kevin schmidt
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic