开发者

How to read files from a folder and use them in an arrary

I am Trying to read all the files in a folder and create an arrary with the data. I know there may be other topics with this but i am having trouble searching For the answer.

Heres the code i am using

import java.io.File;

public class test3 {
publi开发者_Go百科c static void main( String [] args ) {
    File actual = new File("."); //replace . with file path
    int x = 1;
    for( File f : actual.listFiles()){
        System.out.println( x + ". " + f.getName() );
        x++;
    }
}}

Thanks


Here's an example that shows how to read from a file.

Inside that loop you have to open the file, read its contents, and add it to another array or List. Then you can search through the contents of each one.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜