If you are looking for some file management, this will definitely be handy:
package utils;
import java.io.*;
import java.nio.ByteBuffer;
import java.util.Arrays;
public class Files {
private static final String file_name = "descrambler_wordlist.txt";
public static byte[][] dictionary;
private static int dic_words = 0;
public final static int WORDS_NO = 234204;
private static ByteBuffer currentlyParsingB;
public static void parseDictionary()
{
FileInputStream fis;
File file = new File(file_name);
int len = 1024 * 512; //512KB
currentlyParsingB = ByteBuffer.allocate(24);
//currentlyParsing = new byte[24];
dictionary = new byte[WORDS_NO][];
try {
fis = new FileInputStream(file);
} catch (FileNotFoundException e1) {
fis = null;
e1.printStackTrace();
}
byte[] b = new byte[len];
int bread;
try {
fis = new FileInputStream(file);
while((bread = fis.read(b, 0, len))!=-1)
parseBlock(b, bread);
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
private static void parseBlock(byte[] b, int l)
{
byte b1;
for(int j=0; j<l; j++)
{
b1 = b[j];
if(b1==10)
{
dictionary[dic_words] = Arrays.copyOf(currentlyParsingB.array(), currentlyParsingB.position());
currentlyParsingB.clear();
//word_pos = 0;
dic_words++;
}
else
{
currentlyParsingB.put(b1);
//currentlyParsing[word_pos] = b1;
//word_pos++;
}
}
}
}
It's old code from a dictionary parser. There's extra stuff there but I guess you can easily find what you need. :)