• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

formatting output incorrectly

 
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
 
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).]
 
I'm not dead! I feel happy! I'd like to go for a walk! I'll even read a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic