// Create the entry on the floppy
FsDirectoryEntry floppyEntry = fs.getRoot().addFile(children[i]);
//floppyEntry.setName(children[i]);
System.out.print("- Processing file: "+children[i]+" ");
FsFile floppyfile = floppyEntry.getFile();
// Copy the file over
if (aFile.isFile()) {
FileInputStream fis= new FileInputStream(aFile);
FileChannel fci = fis.getChannel();
ByteBuffer buffer = ByteBuffer.allocate(1024);
long counter=0;
int len;
// http://www.kodejava.org/examples/49.html
// Here we start to read the source file and write it
// to the destination file. We repeat this process
// until the read method of input stream channel return
// nothing (-1).
while(true)
{
// read a block of data and put it in the buffer
int read = fci.read(buffer);
// did we reach the end of the channel? if yes
// jump out the while-loop
if (read == -1)
break;
// flip the buffer
buffer.flip();
// write to the destination channel
System.out.print(".");
floppyfile.write(counter*1024, buffer);
counter++;
// clear the buffer and user it for the next read
// process
buffer.clear();
}
System.out.println();
floppyfile.flush();
fis.close();
}
} catch (IOException e) {
// TODO Auto-generated catch block