Examples of RandomAccessFile


Examples of java.io.RandomAccessFile

    private FileLock lock;
    private long length;

    FileObjectDiskChannel(String fileName, String mode) throws IOException {
        this.name = fileName;
        file = new RandomAccessFile(fileName, mode);
        channel = file.getChannel();
        length = file.length();
    }
View Full Code Here

Examples of java.io.RandomAccessFile

     * @param pageSize should be greater than or equals to 64k.
     */
    public MemoryMappedFile(final File file, final int pageShift, final boolean readOnly, final boolean nativeByteOrder)
            throws FileNotFoundException {
        this._filepath = file.getAbsolutePath();
        RandomAccessFile raf = new RandomAccessFile(file, readOnly ? "r" : "rw");
        this._channel = raf.getChannel();
        this._readOnly = readOnly;
        this._setAsLittleEndian = nativeByteOrder
                && (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN);
        this._pageSize = 1 << pageShift;

View Full Code Here

Examples of org.apache.pdfbox.io.RandomAccessFile

            //  for unpacked / processed resources
            // Decide which to do based on if we're reading from a file or not already
            TikaInputStream tstream = TikaInputStream.cast(stream);
            if (tstream != null && tstream.hasFile()) {
                // File based, take that as a cue to use a temporary file
                RandomAccess scratchFile = new RandomAccessFile(tmp.createTemporaryFile(), "rw");
                if (localConfig.getUseNonSequentialParser() == true){
                    pdfDocument = PDDocument.loadNonSeq(new CloseShieldInputStream(stream), scratchFile);
                } else {
                    pdfDocument = PDDocument.load(new CloseShieldInputStream(stream), scratchFile, true);
                }
View Full Code Here

Examples of org.pdfbox.io.RandomAccessFile

            {
                ximage = new PDJpeg(doc, new FileInputStream( image ) );
            }
            else if (image.toLowerCase().endsWith(".tif") || image.toLowerCase().endsWith(".tiff"))
            {
                ximage = new PDCcitt(doc, new RandomAccessFile(new File(image),"r"));
            }
            else
            {
                //BufferedImage awtImage = ImageIO.read( new File( image ) );
                //ximage = new PDPixelMap(doc, awtImage);
View Full Code Here

Examples of ucar.unidata.io.RandomAccessFile

    // Reading of Grib files must be inside a try-catch block
    calendar = Calendar.getInstance();
    calendar.setTimeZone(java.util.TimeZone.getTimeZone("GMT"));
    PrintStream ps = System.out;
    try {
      RandomAccessFile raf = null;
      if (args.length == 3) {  // input file, output file, get data for dump
        raf = new RandomAccessFile(args[0], "r");
        ps = new PrintStream(
                new BufferedOutputStream(
                        new FileOutputStream(args[1], false)));
        displayData = args[2].equalsIgnoreCase("true");
      } else if (args.length == 2) {  // input file and output file for dump
        raf = new RandomAccessFile(args[0], "r");
        if (args[1].equalsIgnoreCase("true")
                || args[1].equalsIgnoreCase("false")) {
          displayData = args[1].equalsIgnoreCase("true");
        } else {
          ps = new PrintStream(
                  new BufferedOutputStream(
                          new FileOutputStream(args[1], false)));
        }
      } else if (args.length == 1) {
        raf = new RandomAccessFile(args[0], "r");
      } else {
        System.exit(0);
      }
      // test for a user defined parameter table read
      //GribPDSParamTable.addParameterUserLookup( "/local/robb/trunk20081229/grib/resources/resources/grib/tables/userlookup.lst");
      raf.order(RandomAccessFile.BIG_ENDIAN);
      // Create Grib1Input instance
      Grib1Input g1i = new Grib1Input(raf);
      // boolean params getProducts, oneRecord
      g1i.scan(false, false);
      // record contains objects for all 5 Grib1 sections
      ArrayList records = g1i.getRecords();
      for (int i = 0; i < records.size(); i++) {
        Grib1Record record = (Grib1Record) records.get(i);
        Grib1IndicatorSection is = record.getIs();
        Grib1ProductDefinitionSection pds = record.getPDS();
        Grib1GridDefinitionSection gds = record.getGDS();

        // create dump output here
        ps.println(
                "--------------------------------------------------------------------");
        ps.println("                        Header : "
                + record.getHeader());
        printIS(is, ps);
        printPDS(pds, ps);
        printGDS(gds, pds, ps);
        ps.println();

        if (displayData) {
          float[] data = null;
          ps.println(
                  "--------------------------------------------------------------------");
          Grib1Data gd = new Grib1Data(raf);
          // TODO: pds vars needed
          data = gd.getData(record.getDataOffset(),
                  pds.getDecimalScale(), pds.bmsExists());
          if (data != null) {
            for (int j = 0; j < data.length; j++) {
              ps.println("data[ " + j + " ]=" + data[j]);
            }
          }
          break// only display data for 1st record
        }
      }
      raf.close();    // done reading

      // Catch thrown errors from GribFile
    } catch (FileNotFoundException noFileError) {
      System.err.println("FileNotFoundException : " + noFileError);
    } catch (IOException ioError) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.