Im trying to limit the size creation of one file in my java app. For that I made this sample code which I declare one variable lenght of 32 bytes, start WriteOnFile method looping it until 32 bytes. The problem is, it doesnt matter the value I set set on FILE_SIZE (Higher or lower) the download file is always coming with 400kb - that means my code is working since the original file is 200Mb but has some logic mistake. is there another way to do this? cos I based myself on this post How to limit the file size in Java and until now found nothing better
I was wondering if this has something with the bufferedwriter...
Thanks in advance for the help
public static final byte FILE_SIZE = 32;
private static void WriteOnFile(BufferedWriter writer, String crawlingNode){
try {
while(file.length()<FILE_SIZE){
writer.write(crawlingNode);
System.out.println(file.length());
}
} catch (IOException e) {
JOptionPane.showMessageDialog(null, "Failed to write URL Node");
e.printStackTrace();
}
}