Hi HashCode. An interesting question, help make such a program, if not difficult, of course. Write 1 it prints the first ten files, write 2 it prints the next ten, and so on until the files run out in the directory (they are taken from the folder, regular txt files) . In general, like this). Here's a code to help you, although I don’t know if it can help:
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.List; public class page { public static void main(String[] args) { String s = null; File file = new File("C:\\prov"); String list[] = file.list(); int len = new File("C:\\prov\\").list().length; ArrayList<String> pages = new ArrayList<String>(); for (int i = 1; i <= len; i++) { for (int itt = 0; itt < list.length; itt++) { File fileread = new File("C:\\prov\\" + list[itt]); BufferedReader brl = null; try { brl = new BufferedReader(new InputStreamReader( new FileInputStream(fileread), "UTF-8")); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } // pages.add("page-" + i); try { while ((s = brl.readLine()) != null) { pages.add(s); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } paginate(pages, 10); }// main end static <T> void paginate(List<T> pages, int pagesPerOut) { for (int i = 0; i < pages.size(); i += pagesPerOut) { System.out.println(paginate(pages, i, pagesPerOut)); System.out.println("=============================="); } } static <T> List<T> paginate(List<T> pages, int start, int count) { int end = start + count > pages.size() ? pages.size() : start + count; return pages.subList(start, end); } }
Of course, I understand that they will not write code like this, but there may be good people who are ready to help.