22 package com.realtime.crossfire.jxclient.sound;
27 import java.io.FileInputStream;
28 import java.io.FileNotFoundException;
29 import java.io.IOException;
30 import java.io.InputStream;
31 import org.jetbrains.annotations.NotNull;
32 import org.jetbrains.annotations.Nullable;
65 public InputStream
getInputStream(@Nullable
final String name, @NotNull
final String action)
throws IOException {
66 @Nullable
final IOException savedException;
68 savedException = null;
72 }
catch (
final IOException ex) {
79 }
catch (
final IOException ex) {
80 throw savedException == null ? ex : savedException;
91 private InputStream
getResource(@NotNull
final String name)
throws IOException {
92 final String resource =
"resource/sounds/"+name+
".wav";
94 @Nullable File localFile;
96 localFile =
new File(resource).getCanonicalFile();
97 }
catch (
final IOException ex) {
98 if (debugSound != null) {
99 debugSound.
debugProtocolWrite(
"resource: ["+resource+
"] not found as file:"+resource+
" ("+ex.getMessage()+
")");
103 if (localFile != null) {
105 final InputStream inputStream =
new FileInputStream(localFile);
106 if (debugSound != null) {
110 }
catch (
final FileNotFoundException ignored) {
111 if (debugSound != null) {
112 debugSound.
debugProtocolWrite(
"resource: ["+resource+
"] not found as file:"+localFile);
119 final InputStream inputStream =
new FileInputStream(file);
120 if (debugSound != null) {
124 }
catch (
final FileNotFoundException ignored) {
125 if (debugSound != null) {
130 final InputStream inputStream =
AudioFileLoader.class.getClassLoader().getResourceAsStream(resource);
131 if (inputStream != null) {
132 if (debugSound != null) {
137 if (debugSound != null) {
138 debugSound.
debugProtocolWrite(
"resource: ["+resource+
"] not found as rsrc:"+resource);
141 throw new IOException(
"resource "+resource+
" does not exist");
final DebugWriter debugSound
The writer for logging sound related information or.
Utility class to return references to settings files.
void debugProtocolWrite(@NotNull final CharSequence str)
Writes a message to the debug protocol.
Writer debug information to a log file.
AudioFileLoader(@Nullable final DebugWriter debugSound)
Private constructor to prevent instantiation.
static File getSettingsFile()
Returns the main settings file.
InputStream getInputStream(@Nullable final String name, @NotNull final String action)
Returns an input stream for an audio file.
InputStream getResource(@NotNull final String name)
Returns an input stream for an audio file.