音频可以分段的播放,视频不可以
public native void setDataSource(FileDescriptor fd, long offset, long length)
throws IOException, IllegalArgumentException, IllegalStateException;
mPlayer.setDataSource(fis.getFD(),0,1000*1024);
可以指定从音频文件的那里开始播放
FileDescriptor:相当于文件的句柄。
java 文件流的删除 需要注意的地方:
File file = new File("11.txt");
FileOutputStream out = new FileOutputStream(file);
out.write("zhangweia".getBytes(),0,2);
System.out.println("hello");
out.flush();
out.close(); 必须调用out.close():关闭流了才可以删除文件,否则删除不起效果
file.delete();
/*out.write("good adira".getBytes(),0,5);
out.flush();*/
System.out.println("hello");
字节数组的合并:
java.io.ByteArrayOutputStream baos;
baos.write(byte[] data, int offset, int length);
baos.toByteArray();
其实他本身还是调用System.arraycopy(),但是通过巧妙的处理,使得没有200次那么多,具体可以查看JDK中自己带的源代码
System.out.println(Arrays.toString(bytes)); byte数组的打印
浙公网安备 33010602011771号