I have this Java code, which should read a 0.5M files and write after removing some useless information(I’m using Enron E-mails Dataset)
public void getInboxFiles(File directory){
File[] usersFolders;
File[] userFolders;
File[] inboxFiles;
usersFolders = directory.listFiles();
for(File temp:usersFolders){
userFolders = temp.listFiles();
for(File temp2:userFolders){
inboxFiles = temp2.listFiles();
for(File tmp3:inboxFiles){
if(tmp3.isDirectory())
continue;
readNPrase(tmp3, new File("/media/ADATA SH12/datasets/parsedEnron/"+temp.getName()+tmp3.getName()+".txt"));
}
}
}
}
the function readNParse is:
public void readNPrase(File in,File out){
BufferedReader br=null;
BufferedWriter bw =null;
try{
br = new BufferedReader(new FileReader(in));
bw= new BufferedWriter(new FileWriter(out));
boolean messageContent = false;
String line = null;
while((line = br.readLine()) != null){
if(line.trim().equals(""))
messageContent = true;
if(messageContent && !isHeader(line) && !line.trim().equals("")){
bw.write(line);
bw.newLine();
}
}
bw.flush();
br.close();
bw.close();
} catch (IOException e) {
e.printStackTrace();
}finally{
try{
bw.close();
br.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
after running this code for 10 minuets it stops working and gave me this error:
java.lang.NullPointerException java.io.FileNotFoundException: /media/ADATA SH12/datasets/parsedEnron/causholli-m98.txt (No space left on device)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
at java.io.FileOutputStream.<init>(FileOutputStream.java:171)
at java.io.FileWriter.<init>(FileWriter.java:90)
at EnronMailParser.readNPrase(EnronMailParser.java:16)
at EnronMailParser.getInboxFiles(EnronMailParser.java:71)
at EnronMailParser.main(EnronMailParser.java:84)
I checked the space on the drive but there is a too much of empty space some of people said it is related to file name, and some said it is related to inode which is an os issue, I have no idea what is it and how it solve it. I am on Ubuntu 12.04.