当前位置: 首页>>代码示例>>Java>>正文


Java MidiFileWriter.write方法代码示例

本文整理汇总了Java中javax.sound.midi.spi.MidiFileWriter.write方法的典型用法代码示例。如果您正苦于以下问题:Java MidiFileWriter.write方法的具体用法?Java MidiFileWriter.write怎么用?Java MidiFileWriter.write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.sound.midi.spi.MidiFileWriter的用法示例。


在下文中一共展示了MidiFileWriter.write方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: write

import javax.sound.midi.spi.MidiFileWriter; //导入方法依赖的package包/类
/**
 * Writes a stream of bytes representing a file of the MIDI file type
 * indicated to the output stream provided.
 * @param in sequence containing MIDI data to be written to the file
 * @param fileType the file type of the file to be written to the output stream
 * @param out stream to which the file data should be written
 * @return the number of bytes written to the output stream
 * @throws IOException if an I/O exception occurs
 * @throws IllegalArgumentException if the file format is not supported by
 * the system
 * @see #isFileTypeSupported(int, Sequence)
 * @see     #getMidiFileTypes(Sequence)
 */
public static int write(Sequence in, int fileType, OutputStream out) throws IOException {

    List providers = getMidiFileWriters();
    //$$fb 2002-04-17: Fix for 4635287: Standard MidiFileWriter cannot write empty Sequences
    int bytesWritten = -2;

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = (MidiFileWriter) providers.get(i);
        if( writer.isFileTypeSupported( fileType, in ) ) {

            bytesWritten = writer.write(in, fileType, out);
            break;
        }
    }
    if (bytesWritten == -2) {
        throw new IllegalArgumentException("MIDI file type is not supported");
    }
    return bytesWritten;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:MidiSystem.java

示例2: write

import javax.sound.midi.spi.MidiFileWriter; //导入方法依赖的package包/类
/**
 * Writes a stream of bytes representing a file of the MIDI file type
 * indicated to the output stream provided.
 *
 * @param  in sequence containing MIDI data to be written to the file
 * @param  fileType the file type of the file to be written to the output
 *         stream
 * @param  out stream to which the file data should be written
 * @return the number of bytes written to the output stream
 * @throws IOException if an I/O exception occurs
 * @throws IllegalArgumentException if the file format is not supported by
 *         the system
 * @throws NullPointerException if {@code in} or {@code out} are
 *         {@code null}
 * @see #isFileTypeSupported(int, Sequence)
 * @see #getMidiFileTypes(Sequence)
 */
public static int write(final Sequence in, final int fileType,
                        final OutputStream out) throws IOException {
    Objects.requireNonNull(in);
    Objects.requireNonNull(out);

    List<MidiFileWriter> providers = getMidiFileWriters();
    //$$fb 2002-04-17: Fix for 4635287: Standard MidiFileWriter cannot write empty Sequences
    int bytesWritten = -2;

    for (int i = 0; i < providers.size(); i++ ) {
        MidiFileWriter writer = providers.get(i);
        if( writer.isFileTypeSupported( fileType, in ) ) {

            bytesWritten = writer.write(in, fileType, out);
            break;
        }
    }
    if (bytesWritten == -2) {
        throw new IllegalArgumentException("MIDI file type is not supported");
    }
    return bytesWritten;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:40,代码来源:MidiSystem.java

示例3: write

import javax.sound.midi.spi.MidiFileWriter; //导入方法依赖的package包/类
/**
 * Write a sequence to an output stream using a specific MIDI file format.
 *
 * @param in the sequence to write
 * @param fileType the MIDI file format to use
 * @param out the output stream to write to
 * @return the number of bytes written
 * @throws IOException if an I/O exception happens
 * @throws IllegalArgumentException if fileType is not supported for in
 */
public static int write(Sequence in, int fileType, OutputStream out)
  throws IOException
{
  Iterator writers = ServiceFactory.lookupProviders(MidiFileWriter.class);
  while (writers.hasNext())
  {
    MidiFileWriter fw = (MidiFileWriter) writers.next();

    if (fw.isFileTypeSupported(fileType, in))
      return fw.write(in, fileType, out);
  }
  throw new IllegalArgumentException("File type "
                                     + fileType + " is not supported");
}
 
开发者ID:vilie,项目名称:javify,代码行数:25,代码来源:MidiSystem.java

示例4: write

import javax.sound.midi.spi.MidiFileWriter; //导入方法依赖的package包/类
/**
 * Write a sequence to an output stream using a specific MIDI file format.
 * 
 * @param in the sequence to write
 * @param fileType the MIDI file format to use
 * @param out the output stream to write to
 * @return the number of bytes written
 * @throws IOException if an I/O exception happens
 * @throws IllegalArgumentException if fileType is not supported for in
 */
public static int write(Sequence in, int fileType, OutputStream out)
  throws IOException
{
  Iterator writers = ServiceFactory.lookupProviders(MidiFileWriter.class);
  while (writers.hasNext())
  {
    MidiFileWriter fw = (MidiFileWriter) writers.next();
  
    if (fw.isFileTypeSupported(fileType, in))
      return fw.write(in, fileType, out);
  }
  throw new IllegalArgumentException("File type " 
		       + fileType + " is not supported");
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:25,代码来源:MidiSystem.java

示例5: write

import javax.sound.midi.spi.MidiFileWriter; //导入方法依赖的package包/类
/**
 * Write a sequence to an output stream using a specific MIDI file format.
 *
 * @param in the sequence to write
 * @param fileType the MIDI file format to use
 * @param out the output stream to write to
 * @return the number of bytes written
 * @throws IOException if an I/O exception happens
 * @throws IllegalArgumentException if fileType is not supported for in
 */
public static int write(Sequence in, int fileType, OutputStream out)
  throws IOException
{
  Iterator<MidiFileWriter> writers = ServiceFactory.lookupProviders(MidiFileWriter.class);
  while (writers.hasNext())
  {
    MidiFileWriter fw = (MidiFileWriter) writers.next();

    if (fw.isFileTypeSupported(fileType, in))
      return fw.write(in, fileType, out);
  }
  throw new IllegalArgumentException("File type "
                                     + fileType + " is not supported");
}
 
开发者ID:cfriedt,项目名称:classpath,代码行数:25,代码来源:MidiSystem.java


注:本文中的javax.sound.midi.spi.MidiFileWriter.write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。