public boolean isEnoughSpaceInSDcard(long fileSize) { if (Environment.MEDIA_MOUNTED.equals(Environment .getExternalStorageState())) { long avaliableSize = 0; String storageDirectory = null; storageDirectory = Environment.getExternalStorageDirectory() .getAbsolutePath(); LogUtil.d("erik", "getAvailableStorage. storageDirectory : " + storageDirectory); try { StatFs stat = new StatFs(storageDirectory); avaliableSize = ((long) stat.getAvailableBlocks() * (long) stat .getBlockSize()); LogUtil.d("erik", "getAvailableStorage. avaliableSize : " + avaliableSize); } catch (RuntimeException ex) { return false; } return avaliableSize > fileSize; } else { return false; } }
生活中难免有多种选择,你自己也可以拥有一些选择,在wap开发中肯定也是可以的!
下面是源代码:
<?xml version="1.0" encoding="gb2312"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="multipselect" title="多项选择">
<p>
<br/>
<b>你喜欢吃哪些快餐?</b>
<select multiple="true" name="food" iname="i" ivalue="1;2">
<option value="麦当劳">麦当劳</option>
<option value="肯德基">肯德基</option>
<option value="大排档">大排档</option>
<option value="必胜客">必胜客</option>
</select>
你可以同时选多个选项后确认<br/>
<do type="accept" label="确认">
<go href="#status"/>
</do>
</p>
</card>
<card id="status" title="选择结果">
<p>
<br/>
你的嗜好是:$food
</p>
</card>
</wml>
说明:注意中文乱码问题。
import java.util.concurrent.Callable;
import
java.util.concurrent.ExecutionException;
import
java.util.concurrent.Executors;
import
java.util.concurrent.ScheduledExecutorService;
import
java.util.concurrent.ScheduledFuture;
import
java.util.concurrent.TimeUnit;
public class ScheduledExecutorServiceTest
{
public static void
main(String[] args) throws InterruptedException,ExecutionException
{
//*1
ScheduledExecutorService
service=Executors.newScheduledThreadPool(2);
//*2
Runnable task1=new Runnable()
{
public void run()
{
System.out.println("Taskrepeating.");
}
};
//*3
final ScheduledFuture
future1=service.scheduleAtFixedRate(task1,0,1,TimeUnit.SECONDS);
//*4
ScheduledFuture future2=service.schedule(new
Callable()
{
public String
call()
{
future1.cancel(true);
return
"taskcancelled!";
}
},10,TimeUnit.SECONDS);
System.out.println(future2.get());
//*5
service.shutdown();
}
}
这个例子有两个任务,第一个任务每隔一秒打印一句“Taskrepeating”,第二个任务在5秒钟后取消第一个任务。
*5:关闭服务。