RandomAccessFile: close() : RandomAccessFile « java.io « Java by API






RandomAccessFile: close()

  
import java.io.File;
import java.io.FileInputStream;
import java.io.RandomAccessFile;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class Main {
  public static void main(String[] args) throws Exception{
    ZipInputStream zipinputstream = new ZipInputStream(new FileInputStream("filename"));
    ZipEntry zipentry = zipinputstream.getNextEntry();
    while (zipentry != null) {
      String entryName = zipentry.getName();
      File newFile = new File(entryName);
      String directory = newFile.getParent();
      if (directory == null) {
        if (newFile.isDirectory())
          break;
      }
      RandomAccessFile  rf = new RandomAccessFile(entryName, "r");
      String line;
      if ((line = rf.readLine()) != null) {
        System.out.println(line);
      }
      rf.close();
      zipinputstream.closeEntry();
      zipentry = zipinputstream.getNextEntry();
    }
    zipinputstream.close();
  }
}

   
    
  








Related examples in the same category

1.new RandomAccessFile(String fileName, String mode)
2.RandomAccessFile: getChannel()
3.RandomAccessFile: getFilePointer()
4.RandomAccessFile: length()
5.RandomAccessFile: read(byte[] b)
6.RandomAccessFile: readBoolean()
7.RandomAccessFile: readByte()
8.RandomAccessFile: readChar()
9.RandomAccessFile: readDouble()
10.RandomAccessFile: readInt()
11.RandomAccessFile: readLine()
12.RandomAccessFile: seek(long pos)
13.RandomAccessFile: write(byte[] b)
14.RandomAccessFile: writeBoolean(boolean v)
15.RandomAccessFile: writeBytes(String s)
16.RandomAccessFile: writeChar(int v)
17.RandomAccessFile: writeChars(String s)
18.RandomAccessFile: writeDouble(double v)
19.RandomAccessFile: writeInt(int v)
20.RandomAccessFile: writeUTF(String str)