Add in a small async web util.
This commit is contained in:
parent
28f96fcab0
commit
746ce7fb55
47
src/com/massivecraft/mcore/util/WebUtil.java
Normal file
47
src/com/massivecraft/mcore/util/WebUtil.java
Normal 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();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user