<commit_before>import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.LinkedList;

public class FilterLineReader {

	private String filter;
	private RandomAccessFile file;
	
	public FilterLineReader(String fileToRead)
	{
		filter = "";
		
		try{
			file = new RandomAccessFile(fileToRead, "rw");
		}catch (FileNotFoundException e)
		{
			System.out.println(e);
		}
	}
	
	public FilterLineReader(String fileToRead, String newfilter)
	{
		this(fileToRead);
		
		this.filter = new String(newfilter);
	}
	
	public LinkedList<String> getLinesAfterFilterAndMoveIt(int numberOfLines)
	{
		LinkedList<String> ret = getSomeLinesAfterFilter(numberOfLines);
		
		moveFilterAfterString(ret.getLast());
		
		ret = stringAdjuster.AdjustToBookList(ret);
		
		return ret;
	}
	
	private LinkedList<String> getSomeLinesAfterFilter(int numberOfLines)
	{
		LinkedList<String> ret = new LinkedList<>();
		
		if(!filter.isEmpty())
		{
			String currLine;
			boolean found = false;
			
			try{
				file.seek(0);
				while( (currLine = file.readLine()) != null)
				{
					if(found && numberOfLines > 0){
						--numberOfLines;
						ret.add(currLine);
					}
					else if(currLine.contains(filter))
					{
						found = true;
					}
					else if(numberOfLines == 0)
					{
						break;
					}
				}
			}catch(IOException e){
				ret.clear();
			}
		}
		
		return ret;
	}
	
	private void moveFilterAfterString(String putFilterAfter)
	{
		if(!filter.isEmpty() && !putFilterAfter.isEmpty())
		{
			String currLine;
			String newContent = "";
			try{
				file.seek(0);
				while( (currLine = file.readLine()) != null)
				{
					if(currLine.contains(filter))
					{
						currLine = currLine.replace(filter, "");
						
					}
					if(currLine.equals(putFilterAfter))
					{
						currLine += " " + filter;
					}
					
					newContent += currLine + '\n';
				}
				System.out.println("Prbuje nadpisa: ");
				file.setLength(0);
				file.seek(0);
				file.writeBytes(newContent);
				
			}catch(IOException e){
				System.out.println(e);
			}
		}
	}
	
}
<commit_msg>Added getLine and setFilter to FilterLineReader<commit_after>import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.LinkedList;

public class FilterLineReader {

	private String filter;
	private RandomAccessFile file;
	
	public FilterLineReader(String fileToRead)
	{
		filter = "";
		
		try{
			file = new RandomAccessFile(fileToRead, "rw");
		}catch (FileNotFoundException e)
		{
			System.out.println(e);
		}
	}
	
	public FilterLineReader(String fileToRead, String newfilter)
	{
		this(fileToRead);
		
		this.filter = new String(newfilter);
	}
	
	public LinkedList<String> getLinesAfterFilterAndMoveIt(int numberOfLines)
	{
		LinkedList<String> ret = getSomeLinesAfterFilter(numberOfLines);
		
		moveFilterAfterString(ret.getLast());
		
		ret = stringAdjuster.AdjustToBookList(ret);
		
		return ret;
	}
	
	public LinkedList<String> getLinewsWithFilter()
	{		
		LinkedList<String> ret = new LinkedList<>();
		
		if(!filter.isEmpty())
		{
			String currLine;
			try{
				file.seek(0);
				
				while( (currLine = file.readLine()) != null){
					if(currLine.contains(filter))
						ret.add(currLine);
					
				}
			}catch(IOException e){
				ret.clear();
			}
		}
				
		return ret;
	}
	
	private LinkedList<String> getSomeLinesAfterFilter(int numberOfLines)
	{
		LinkedList<String> ret = new LinkedList<>();
		
		if(!filter.isEmpty())
		{
			String currLine;
			boolean found = false;
			
			try{
				file.seek(0);
				while( (currLine = file.readLine()) != null)
				{
					if(found && numberOfLines > 0){
						--numberOfLines;
						ret.add(currLine);
					}
					else if(currLine.contains(filter))
					{
						found = true;
					}
					else if(numberOfLines == 0)
					{
						break;
					}
				}
			}catch(IOException e){
				ret.clear();
			}
		}
		
		return ret;
	}
	
	private void moveFilterAfterString(String putFilterAfter)
	{
		if(!filter.isEmpty() && !putFilterAfter.isEmpty())
		{
			String currLine;
			String newContent = "";
			try{
				file.seek(0);
				while( (currLine = file.readLine()) != null)
				{
					if(currLine.contains(filter))
					{
						currLine = currLine.replace(filter, "");
						
					}
					if(currLine.equals(putFilterAfter))
					{
						currLine += " " + filter;
					}
					
					newContent += currLine + '\n';
				}
				System.out.println("Prbuje nadpisa: ");
				file.setLength(0);
				file.seek(0);
				file.writeBytes(newContent);
				
			}catch(IOException e){
				System.out.println(e);
			}
		}
	}
	
	
	public void setFilter(String newFilter)
	{
		if(!filter.equals(newFilter))
			this.filter = newFilter;
	}
}

{'fraction_non_alphanumeric': 0.12912785774767147, 'fraction_numerical': 0.00275190516511431, 'mean_word_length': 2.9081885856079404, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5598324', 'n_tokens_mistral': 2059, 'n_tokens_neox': 1553, 'n_words': 279}