Add in a small async web util.

This commit is contained in:
Olof Larsson 2013-06-07 09:31:14 +02:00
parent 28f96fcab0
commit 746ce7fb55

View File

@ -0,0 +1,47 @@
package com.massivecraft.mcore.util;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class WebUtil
{
private static final ExecutorService executor = Executors.newSingleThreadExecutor();
public static void asyncGetTouch(String url)
{
try
{
asyncGetTouch(new URL(url));
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
}
public static void asyncGetTouch(final URL url)
{
executor.execute(new Runnable()
{
@Override
public void run()
{
try
{
InputStream inputStream = null;
inputStream = url.openStream();
inputStream.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
});
}
}