All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nyla.solutions.core.io.FolderFileTokenizer Maven / Gradle / Ivy

Go to download

This Java API provides support for application utilities (application configuration, data encryption, debugger, text processing, and more).

The newest version!
package nyla.solutions.core.io;

import nyla.solutions.core.exception.RequiredException;
import nyla.solutions.core.util.Config;

import java.io.File;
import java.util.ArrayList;
import java.util.Collection;

import static nyla.solutions.core.util.Config.settings;


public class FolderFileTokenizer
{
	private ArrayList fileList = null;
	private String listFilter = settings().getProperty(this.getClass(),"listFilter","*.*");
	private File folder = null;

	/**
	 * @return the folder
	 */
	public Collection getFileTokenizer()
	{
		return fileList;
	}//---------------------------------------------

	/**
	 * @param folder the folder to set
	 */
	public void setFolder(File folder)
	{
		if(folder == null)
			throw new RequiredException("folder in FolderFileTokenizer");
		
		if(!folder.isDirectory())
			throw new RequiredException("valid folder "+folder.getAbsolutePath());
		
		this.folder = folder;
		
		File[] files = IO.listFiles(this.folder, this.listFilter);
		
		fileList = new ArrayList(files.length);
		for(int i=0;i < files.length;i++)
		{
			fileList.add(new FileTokenizer(files[i]));
		}
		
	}

	/**
	 * @return the listFilter
	 */
	public String getListFilter()
	{
		return listFilter;
	}

	/**
	 * @param listFilter the listFilter to set
	 */
	public void setListFilter(String listFilter)
	{
		this.listFilter = listFilter;
	}

	/**
	 * @return the folder
	 */
	public File getFolder()
	{
		return folder;
	}


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy