Tag: 重置

java.io.IOException:标记/重置不支持Java音频输入流/缓冲输入流

我正在创建一个2D Java平台游戏,我正试图在游戏运行时从.wav文件中播放音频…… 下面是我创建的AudioPlayer类,用于将资源加载到音频输入流中 import javax.sound.sampled.*; import java.io.*; import java.util.*; import java.net.*; public class AudioPlayer { private Clip clip; public AudioPlayer(String s) { try { /************/ InputStream is = getClass().getResourceAsStream(s); AudioInputStream ais; BufferedInputStream bis = new BufferedInputStream(is); ais = AudioSystem.getAudioInputStream(bis); /************/ AudioFormat baseFormat = ais.getFormat(); AudioFormat decodeFormat = new AudioFormat( AudioFormat.Encoding.PCM_SIGNED, baseFormat.getSampleRate(), 16, baseFormat.getChannels(), baseFormat.getChannels() * […]

如何重新执行Log4j“默认初始化过程”?

在运行时,我经常创建/修改log4j Loggers,Appenders,Levels,Layouts以及需要将所有内容重置为默认值的时间。 Log4j系统具有明确定义的默认初始化过程 ,该过程在将log4j类加载到内存时执行。 有没有办法在以后的运行时以编程方式重新执行整个过程? 我在log4j文档中找到了几个resetConfiguration()方法,但不确定它们中的任何一个是否会执行默认初始化过程 : BasicConfigurator.resetConfiguration(); Hierarchy.resetConfiguration(); LogManager.resetConfiguration(); 关于重置log4j配置的任何其他建议都欢迎! 谢谢。

Java Pattern Matcher:创建新的还是重置?

假设一个Regular Expression ,它通过Java Matcher对象与大量字符串匹配: String expression = …; // The Regular Expression Pattern pattern = Pattern.compile(expression); String[] ALL_INPUT = …; // The large number of strings to be matched Matcher matcher; // Declare but not initialize a Matcher for (String input:ALL_INPUT) { matcher = pattern.matcher(input); // Create a new Matcher if (matcher.matches()) // Or whatever […]