Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package lab2;
- import java.util.*;
- import java.io.*;
- class Parser
- {
- public static void citeste(String fisier)
- {
- String buf= " ";
- int c;
- FileReader f = null;
- try
- {
- f = new FileReader(fisier);
- while ((c = f.read()) != -1)
- {
- buf = buf + (char)c;
- }
- f.close();
- }
- catch (FileNotFoundException e)
- {
- System.out.println("Fisierul nu a fost gasit");
- }
- catch (IOException e)
- {
- System.out.println("Eroare la citire");
- }
- }
- public static void getfiles(String file2)
- {
- File folder = new File(file2);
- File[] listOfFiles = folder.listFiles();
- for (File file : listOfFiles) {
- if (file.isFile()) {
- System.out.println(file.getName());
- }
- else if(file.isDirectory()) {
- String name = file.getName();
- getfiles(file2+"/"+name);
- }
- }
- }
- public static void main(String argv[])
- {
- String file="/home/student/Documents/api";
- getfiles(file);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement