<p>Anyone know if it is possible to write an app that uses the Java Sound API on a system that doesn't actually have a hardware sound device?</p>

<p>I have some code I've written based on the API that manipulates some audio and plays the result but I am now trying to run this in a server environment, where the audio will be recorded to a file instead of played to line out.</p>

<p>The server I'm running on has no sound card, and I seem to be running into roadblocks with Java Sound not being able to allocate any lines if there is not a Mixer that supports it. (And with no hardware devices I'm getting no Mixers.)</p>

<p>Any info would be much appreciated -</p>

<p>thanks.</p>

Can this be done with HTTP headers?
Yes, this is the way to go.
If
the information is provided, it's in the header as the
```
Content-Length
```
. Note, however, that this is not necessarily the case.
Downloading only the header can be done using a
```
HEAD
```
request instead of
```
GET
```
. Maybe the following code helps:
```
```
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://example.com/");
req.Method = "HEAD";
long len;
using(HttpWebResponse resp = (HttpWebResponse)(req.GetResponse()))
{
    len = resp.ContentLength;
}
```
```
Notice the property for the content length on the
```
HttpWebResponse
```
object – no need to parse the
```
Content-Length
```
header manually.