/** Reads a full set of bytes (including the header). */ public static MatFile readFull(RandomAccessFile file) throws IOException { MatFileReader reader = new MatFileReader(); reader.read(file, new MatFileFilter(), MatFileReader.HEAP_BYTE_BUFFER); return new MatFile(reader.getMatFileHeader(), reader.getContent()); } }
/** * Reads Matrix name. * * Modifies <code>buf</code> position. * * @param buf <code>ByteBuffer</code> * @return name <code>String</code> * @throws IOException if reading from buffer fails */ private static String readName(ByteBuffer buf, MatFileHeader header) throws IOException { ISMatTag tag = new ISMatTag(buf); return tag.readToString(header.getByteOrder()); }
/** * Writes MLArrays into <code>OuputSteram</code>. * * Writes MAT-file header and compressed data (<code>miCOMPRESSED</code>). * * @param output - <code>OutputStream</code> * @param data - <code>Collection</code> of <code>MLArray</code> elements * @throws IOException */ public MatFileWriter(WritableByteChannel channel, Collection<MLArray> data) throws IOException { write(channel, data); }
MatFileReader mfr = new MatFileReader(tis.getFile()); //input .mat file MatFileHeader hdr = mfr.getMatFileHeader(); //.mat header information String[] parts = hdr.getDescription().split(","); // Break header information into its parts String endianBytes = new String(hdr.getEndianIndicator(), UTF_8); // Retrieve endian bytes and convert to string xhtml.newline(); for (Map.Entry<String, MLArray> entry : mfr.getContent().entrySet()) { String varName = entry.getKey(); MLArray varData = entry.getValue(); MLStructure mlStructure = (MLStructure) mfr.getMLArray(varName); xhtml.startElement("ul"); xhtml.newline();
/** Reads a full set of bytes (including the header). */ public static MatFile readFull(ByteBuffer buf, MatFileType type) throws IOException { MatFileReader reader = new MatFileReader(type); reader.readHeader(buf); while (buf.remaining() > 0) { reader.readData(buf); } return new MatFile(reader.getMatFileHeader(), reader.getContent()); }
/** * Reads the content of a MAT-file and returns the mapped content. * <p> * This method calls <code>read(stream, new MatFileFilter())</code>. * * @param stream * a valid MAT-file stream to be read * @return the same as <code>{@link #getContent()}</code> * @throws IOException * if error occurs during file processing */ public synchronized Map<String, MLArray> read(InputStream stream) throws IOException { return read(stream, new MatFileFilter()); }
/** Reads a bare set of bytes. */ public static Map<String, MLArray> readBare(MatFileHeader header, ByteBuffer buffer) throws IOException { MatFileReader reader = new MatFileReader(); reader.matFileHeader = header; buffer.order(header.getByteOrder()); reader.readData(buffer); return reader.data; }
/** * Creates instance of <code>MatFileReader</code> and reads MAT-file * from <code>file</code>. * * This method reads MAT-file without filtering. * * @param file the MAT-file * @throws IOException when error occurred while processing the file. */ public MatFileReader(File file) throws IOException { this(file, new MatFileFilter(), MatFileType.Regular); }
public void readToByteBuffer(ByteBuffer buff, ByteStorageSupport<?> storage) throws IOException { MatFileInputStream mfis = new MatFileInputStream(buf, type); int elements = size / sizeOf(); mfis.readToByteBuffer(buff, elements, storage); // skip padding if (padding > 0) { buf.position(buf.position() + padding); } }
/** * Create filter intance and add array names. * * @param names - array of names (needles) */ public MatFileFilter(String[] names) { this(); for (String name : names) { addArrayName(name); } }
/** Reads a full set of bytes (including the header). */ public static MatFile readFull(RandomAccessFile file) throws IOException { MatFileReader reader = new MatFileReader(); reader.read(file, new MatFileFilter(), MatFileReader.HEAP_BYTE_BUFFER); return new MatFile(reader.getMatFileHeader(), reader.getContent()); } }
/** Reads a full set of bytes (including the header). */ public static MatFile readFull(ByteBuffer buf, MatFileType type) throws IOException { MatFileReader reader = new MatFileReader(type); reader.readHeader(buf); while (buf.remaining() > 0) { reader.readData(buf); } return new MatFile(reader.getMatFileHeader(), reader.getContent()); }
/** * Reads the content of a MAT-file and returns the mapped content. * <p> * This method calls * <code>read(file, new MatFileFilter(), MallocPolicy.MEMORY_MAPPED_FILE)</code>. * * @param file * a valid MAT-file file to be read * @return the same as <code>{@link #getContent()}</code> * @throws IOException * if error occurs during file processing */ public synchronized Map<String, MLArray> read(File file) throws IOException { return read(file, new MatFileFilter(), MEMORY_MAPPED_FILE); }
/** Reads a bare set of bytes. */ public static Map<String, MLArray> readBare(MatFileHeader header, ByteBuffer buffer) throws IOException { MatFileReader reader = new MatFileReader(); reader.matFileHeader = header; buffer.order(header.getByteOrder()); reader.readData(buffer); return reader.data; }
/** * Reads Matrix name. * * Modifies <code>buf</code> position. * * @param buf <code>ByteBuffer</code> * @return name <code>String</code> * @throws IOException if reading from buffer fails */ private static String readName(ByteBuffer buf, MatFileHeader header) throws IOException { ISMatTag tag = new ISMatTag(buf); return tag.readToString(header.getByteOrder()); }
/** * Writes MLArrays into <code>OuputSteram</code>. * * Writes MAT-file header and compressed data (<code>miCOMPRESSED</code>). * * @param output - <code>OutputStream</code> * @param data - <code>Collection</code> of <code>MLArray</code> elements * @throws IOException */ public MatFileWriter(WritableByteChannel channel, Collection<MLArray> data) throws IOException { write(channel, data); }
/** * Create filter intance and add array names. * * @param names - array of names (needles) */ public MatFileFilter(String[] names) { this(); for (String name : names) { addArrayName(name); } }
/** * Reads the content of a MAT-file and returns the mapped content. * <p> * This method calls <code>read(stream, new MatFileFilter())</code>. * * @param stream * a valid MAT-file stream to be read * @return the same as <code>{@link #getContent()}</code> * @throws IOException * if error occurs during file processing */ public synchronized Map<String, MLArray> read(InputStream stream) throws IOException { return read(stream, new MatFileFilter()); }
/** * Reads the content of a MAT-file and returns the mapped content. * <p> * This method calls * <code>read(file, new MatFileFilter(), MallocPolicy.MEMORY_MAPPED_FILE)</code>. * * @param file * a valid MAT-file file to be read * @return the same as <code>{@link #getContent()}</code> * @throws IOException * if error occurs during file processing */ public synchronized Map<String, MLArray> read(File file) throws IOException { return read(file, new MatFileFilter(), MEMORY_MAPPED_FILE); }