Bonjour,
dans le cadre d'une petite appli Android, j'ai developpé un service qui prend en parametre un tableau de byte avec Ksoap2 et qui me retourne un String.

Le service fonctionne, mais lorsque je fait transiter un fichier audio wav, je ne suis pas capable coté serveur de le recreer.

J'ai donc isoler dans un main, la conversion wav-->byte[] et inversement.
Les tailles de fichiers d'entree et en sortie sont bien les memes, mais mon fichier de sortie n'est pas lisible.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Vector;
 
import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
 
public class Test {
 
	/**
         * @param args
         * @throws IOException
         * @throws UnsupportedAudioFileException
         */
	public static void main(String[] args) throws IOException,
			UnsupportedAudioFileException {
		File fichier = new File("C:/Users/moi/Desktop/03.wav");
		InputStream stream = AudioSystem.getAudioInputStream(fichier);
 
		byte[] buf = new byte[1024];
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		int n;
		while ((n = stream.read(buf, 0, buf.length)) > 0)
			bos.write(buf, 0, n);
		buf = bos.toByteArray();
 
		signalMessage(buf);
	}
 
	public static void signalMessage(byte[] data)
			throws UnsupportedAudioFileException, IOException {
		File dest = new File("C:/Users/moi/Desktop/out.wav");
 
		dest.createNewFile();
 
		ByteArrayInputStream sourceFile = new ByteArrayInputStream(data);
		FileOutputStream destinationFile = new FileOutputStream(dest);
 
		byte buffer[] = new byte[1024];
		int nbLecture;
 
		while ((nbLecture = sourceFile.read(buffer)) != -1) {
			destinationFile.write(buffer, 0, nbLecture);
		}
		destinationFile.close();
		sourceFile.close();
 
	}
}
Merci par avance