Examples of BufferedFile


Examples of net.ivoa.util.BufferedFile

    bhdu.setColumnName(0, "bytes", null);
    bhdu.setColumnName(1, "bits", "bits later on");
    bhdu.setColumnName(6, "doubles", null);
    bhdu.setColumnName(5, "floats", "4 x 4 array");

    BufferedFile bf = new BufferedFile("bt1.fits", "rw");

    f.write(bf);
    bf.flush();
    bf.close();

    // read file
    f = new Fits("bt1.fits");
    BasicHDU hdu;
View Full Code Here

Examples of net.ivoa.util.BufferedFile

      btab.addRow(row);
    }

    f = new Fits();
    f.addHDU(Fits.makeHDU(btab));
    BufferedFile bf = new BufferedFile("bt4.fits", "rw");
    f.write(bf);
    bf.flush();
    bf.close();

    f = new Fits("bt4.fits");

    btab = (BinaryTable) f.getHDU(1).getData();

    // Try getting data before we read in the table.

    xstr = (String[]) btab.getColumn(2);

        //char[] c = btab.getTypes();
        //System.out.println(c[3]);
        boolean[] batest = (boolean[]) btab.getElement(99, 3);
        System.out.println(batest.length);
       
        boolean[] ob = new boolean[]{true, false, true, false};
        System.out.println(ob[0] + " " + ob[1] + " " + ob[2] + " " + ob[3]);
        System.out.println(batest[0] + " " + batest[1] + " " + batest[2] + " " + batest[3]);
       
        btab.setElement(99, 3, ob);
       
    for (int i = 0; i < xstr.length; i++) {

      boolean[] ba = (boolean[]) btab.getElement(i, 3);
      float[] fx = (float[]) btab.getElement(i, 1);
      float[][] tst = (float[][]) btab.getElement(i, 0);
      String s = (String) btab.getElement(i, 2);

      int trow = i % 50;

            System.out.println(vbool[trow].length + " " + ba.length);
      assertEquals(vbool[trow].length, ba.length);
      for (int j = 0; j < ba.length; j += 1) {
        assertEquals(ba[j], vbool[trow][j]);
      }

      assertEquals(vf[trow].length, fx.length);
      for (int j = 0; j < fx.length; j += 1) {
        assertEquals(vf[trow][j], fx[j], 0);
      }
      if (i >= 50)
        assertEquals("new string:" + trow, s);
      else
        assertEquals(strings[i], s);

      // that's for second set of cols
      ba = (boolean[]) btab.getElement(i, 8);
      fx = (float[]) btab.getElement(i, 6);
      tst = (float[][]) btab.getElement(i, 5);
      s = (String) btab.getElement(i, 7);

      assertEquals(vbool[trow].length, ba.length);
      for (int j = 0; j < ba.length; j += 1) {
        assertEquals(ba[j], vbool[trow][j]);
      }

      assertEquals(vf[trow].length, fx.length);
      for (int j = 0; j < fx.length; j += 1) {
        assertEquals(vf[trow][j], fx[j], 0);
      }
      assertEquals(strings[trow], s);
    }
    // Fill the table.
    f.getHDU(1).getData();

    xstr = (String[]) btab.getColumn(2);

    for (int i = 0; i < xstr.length; i += 3) {
      int trow = i % 50;

      String s = (String) btab.getElement(i, 2);
      if (i > 50)
        assertEquals("new string:" + trow, s);
      else
        assertEquals(strings[i], s);
      assertEquals(s, xstr[i]);
    }

    /** * Create a binary table from an Object[][] array */
    Object[][] x = new Object[5][3];
    for (int i = 0; i < 5; i += 1) {
      x[i][0] = new float[]{i};
      x[i][1] = new String("AString" + i);
      x[i][2] = new int[][]{{i, 2 * i}, {3 * i, 4 * i}};
    }

    f = new Fits();
    FitsFactory.setUseAsciiTables(false);
    BasicHDU hdu = Fits.makeHDU(x);
    hdu.toString();
    f.addHDU(hdu);
    bf = new BufferedFile("bt5.fits", "rw");
    f.write(bf);
    bf.close();

    /*File fi = new File("bt1.fits");
    fi.delete();
    fi = new File("bt2.fits");
    fi.delete();
View Full Code Here

Examples of net.sourceforge.fullsync.fs.buffering.BufferedFile

    if (!buffered.isBuffered()) {
      return new State(State.NodeInSync, buffered.exists() ? Location.Both : Location.None);
    }

    File source = buffered.getUnbuffered();
    BufferedFile destination = (BufferedFile) buffered;

    if (!source.exists()) {
      if (!destination.exists()) {
        return new State(State.NodeInSync, Location.None);
      }
      else {
        return new State(State.Orphan, Location.Destination);
      }
    }
    else if (!destination.exists()) {
      return new State(State.Orphan, Location.Source);
    }

    if (source.isDirectory()) {
      if (destination.isDirectory()) {
        return new State(State.NodeInSync, Location.Both);
      }
      else {
        return new State(State.DirHereFileThere, Location.Source);
      }
    }
    else if (destination.isDirectory()) {
      return new State(State.DirHereFileThere, Location.Destination);
    }

    return comparer.compareFiles(source, destination);
  }
View Full Code Here

Examples of net.sourceforge.fullsync.fs.buffering.BufferedFile

  public File createChild(File dir, String name, boolean directory) throws IOException {
    File n = dir.getUnbuffered().getChild(name);
    if (n == null) {
      n = dir.getUnbuffered().createChild(name, directory);
    }
    BufferedFile bf = new AbstractBufferedFile(this, n, dir, directory, false);
    return bf;
  }
View Full Code Here

Examples of net.sourceforge.fullsync.fs.buffering.BufferedFile

  protected void updateFromFileSystem(BufferedFile buffered) throws IOException {
    // load fs entries if wanted
    Collection<File> fsChildren = buffered.getUnbuffered().getChildren();
    for (File uf : fsChildren) {
      BufferedFile bf = (BufferedFile) buffered.getChild(uf.getName());
      if (bf == null) {
        bf = new AbstractBufferedFile(this, uf, root, uf.isDirectory(), false);
        buffered.addChild(bf);
      }
      if (bf.isDirectory()) {
        updateFromFileSystem(bf);
      }
    }
  }
View Full Code Here

Examples of nom.tam.util.BufferedFile

        } else {
            // assume FITS format
            FITSImage fitsImage = getFitsImage();
            if (fitsImage != null && _url != null) {
                try {
                    BufferedFile bf = new BufferedFile(tmpFile, "rw");
                    fitsImage.getFits().write(bf);
                    bf.close();

                    // under Windows, this is necessary to avoid an error
                    fitsImage.getFits().getStream().close();
                } catch (Exception e) {
                    DialogUtil.error(e);
View Full Code Here

Examples of nom.tam.util.BufferedFile

            //System.out.println("XXX FITSImage: using BufferedFile");
            long headerSize = _header.getSize();
            long offset = _hdu.getFileOffset() + headerSize;
            long size = _hdu.getSize() - headerSize;
            //System.out.println("XXX FITSImage: HDU offset = " + offset + ", size = " + size);
            BufferedFile bufferedFile = (BufferedFile) arrayDataInput;
            FileChannel channel = bufferedFile.getChannel();
            System.gc(); // XXX got out of memory errors here    
            _byteBuffer = channel.map(FileChannel.MapMode.READ_ONLY, offset, size);
            //System.out.println("XXX FITSImage: got byteBuffer");
        } else {
            //System.out.println("XXX FITSImage: no byteBuffer access");
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.