javaʵÏÖ×ÊÔ´ÏÂÔØ
/Download by HTTP
//For other protocol, do it yourself
import java.net.*;
import java.io.*;
public class DonwLoad
{
public static void main(String args[])
{
DonwLoad dl =new DonwLoad();
String downfile ="http://www.google.cn/music/top100/url?q=http%3A%2F%2Ffile15.top100.cn%2F201003041353%2FF587B34724657ABBF8CBA990E1C82837%2FSpecial_309548%2F%25E5%258B%2587%25E6%2595%25A2%25E7%2588%25B1.mp3&ct=rdl&cad=dl&ei=2EqPS5jgB4easQLM3920Ag&sig=C56A17F31A0C9FA8BBF93E7ED1AFA8C2"; // can be any file type! Not only htm files can be downloaded.
String saveplace ="c:\\test111.mp3"; //´æ´¢Â·¾¶
if(dl.downLoadFile(downfile,saveplace))
System.out.println("Download ok");
}
public boolean downLoadFile(String fileurl, String savepath)
{
try
{
URL url =new URL(fileurl); //
Ïà¹ØÎĵµ£º
°æÈ¨ÉùÃ÷£º×ªÔØÊ±ÇëÒÔ³¬Á´½ÓÐÎʽ±êÃ÷ÎÄÕÂÔʼ³ö´¦ºÍ×÷ÕßÐÅÏ¢¼°±¾ÉùÃ÷
http://as112255.blogbus.com/logs/38662785.html
package com.softeem.jbs.lesson4;
import java.util.Random;
/**
* ÅÅÐò²âÊÔÀà
*
* ÅÅÐòËã·¨µÄ·ÖÀàÈçÏ£º
* 1.²åÈëÅÅÐò£¨Ö±½Ó²åÈëÅÅÐò¡¢ÕÛ°ë²åÈëÅÅÐ ......
ÊäÈëÊä³öÁ÷
ÔÚJavaÖУ¬ÎÒÃǰÑÄܹ»¶Áȡһ¸ö×Ö½ÚÐòÁеĶÔÏó³Æ×÷Ò»¸öÊäÈëÁ÷;¶øÎÒÃǰѹ»Ð´Ò»¸ö×Ö½ÚÐòÁгÆ×÷Ò»¸öÊä³öÁ÷¡£ËüÃÇ·Ö±ðÓɳéÏóÀà InputStreamºÍOutputStreamÀà±íʾ¡£ÒòÎªÃæÏò×Ö½ÚµÄÁ÷²»·½±ãÓÃÀ´´¦Àí´æ´¢ÎªUnicode£¨Ã¿¸ö×Ö·ûʹÓÃÁ½¸ö×Ö½Ú)µÄÐÅÏ¢¡£ËùÒÔJavaÒýÈëÁËÓÃÀ´´¦ÀíUnicode×Ö·ûµÄÀà²ã´Î£¬ÕâЩÀàÅÉÉú×Ô³éÏóÀàReade ......
synchronized£º ͬ²½µÄ
synchronizedÔÚ²Ù×÷ÉÏÓÐÁ½ÖÖÓ°Ïì¶ÔÏóµÄÇé¿ö£º
1) ÔÚij¸ö¶ÔÏóʵÀýÄÚ£¬synchronized method(){}¿ÉÒÔ·ÀÖ¹¶à¸öÏß³Ìͬʱ·ÃÎÊÕâ¸ö¶ÔÏóµÄsynchronized·½·¨£¨Èç¹ûÒ»¸ö¶ÔÏóÓжà¸ösynchronized·½·¨£¬Ö»ÒªÒ»¸öÏ̷߳ÃÎÊÁËÆäÖеÄÒ»¸ösynchronized·½·¨£¬ÆäËüÏ̲߳»ÄÜͬʱ·ÃÎÊÕâ¸ö¶ÔÏóÖÐÈκÎÒ»¸ösynchronized·½·¨£ ......
1, ΪʲôwaitÓënotify֮ǰ±ØÐëÒª¼Ósynchronized?
´ð°¸ÆäʵºÜ¼òµ¥£¬Ò²ÊÇΪÁË·ÀÖ¹µÈ´ý-֪ͨ»úÖÆ³öÏÖrace condition
Ϊʲô»á³öÏÖrace condition ?
´ð£º ¶ÔÏóÔÚ±»wait֮ǰÒѾ±»ÁíÒ»Ïß³Ìnotify , Ö®ºóµÄwait »áÓÀ¾ÃÍ£Ö¹,²¢µ¼ÖÂdeadlock(ËÀËø)
ÀíÏëÇé¿ö£º
1, µÚÒ»¸öÏß³ÌÅжϸöÔÏóÊÇ·ñÒªwait
2, µÚÒ»¸öÏ߳̽«¶ÔÏówait
3 ......
Ò»¡¢¶àÖÖ·½Ê½¶ÁÎļþÄÚÈÝ¡£
1¡¢°´×Ö½Ú¶ÁÈ¡ÎļþÄÚÈÝ
2¡¢°´×Ö·û¶ÁÈ¡ÎļþÄÚÈÝ
3¡¢°´ÐжÁÈ¡ÎļþÄÚÈÝ
4¡¢Ëæ»ú¶ÁÈ¡ÎļþÄÚÈÝ
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java ......