The Artima Developer Community
Sponsored Link

Java Answers Forum
How to get file name

1 reply on 1 page. Most recent reply: Mar 31, 2002 7:19 PM by Eduardo

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Eduardo

Posts: 21
Nickname: eduardo
Registered: Feb, 2002

How to get file name Posted: Mar 29, 2002 2:29 PM
Reply to this message Reply
Advertisement
I have to read all the files in a certain directory, use its name as a reference, open file by file, read the content, store certain key contents. I don't need to search for the files, as they will always be in the same directory. But how to go to this directory and store the name of the files in a list?

Thanks!


Eduardo

Posts: 21
Nickname: eduardo
Registered: Feb, 2002

Replying to my own question Posted: Mar 31, 2002 7:19 PM
Reply to this message Reply
Okay... okay... I got it myself. But for those who get desperate with those little questions, there you go:

//to point to a directory and read the file names

File path = new File("C:/DirectoryName/DatabaseName/");

String[] list;

list = path.list();
for(int i = 0; i<list.length; i++)
System.out.println(list);

Flat View: This topic has 1 reply on 1 page
Topic: Stale Connections problem.... Previous Topic   Next Topic Topic: ascii in java

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use