JavaʵÏÖ£ºÎļþ´«Êä
//´úÂë¾¹ý±àÒ룬ÔËÐУ¬Ö¤Ã÷¿ÉÒÔÔËÐÐ
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
import java.net.*;
import javax.swing.filechooser.FileFilter;
public class Ftp extends JLabel
{
private JButton openButton;
private JButton saveButton;
JFileChooser fc;
String fileName;
int result;
Ftp()
{
setLayout(new GridLayout());
JButton openButton = new JButton("Open");
openButton.addActionListener(new openFile());
JButton saveButton = new JButton("Save");
saveButton.addActionListener(new saveFile());
add(openButton);
add(saveButton);
}
class openFile implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
fc = new JFileChooser();
result = fc.showOpenDialog(Ftp.this);
File file = fc.getSelectedFile();
if(file != null && result == JFileChooser.APPROVE_OPTION)
{
fileName = file.getAbsolutePath();
System.out.println("Ñ¡ÔñÄãÒª´ò¿ªµÄÎļþ£º" + fileName);
try
{
File file1 = new File(fileName);
FileInputStream fos = new FileInputStream(file1);
ServerSocket ss = new ServerSocket(2048);
Socket client = ss.accept();
OutputStream netOut = client.getOutputStream();
OutputStream doc = new DataOutputStream(new BufferedOutputStream(netOut));
byte[] buf = new byte[2048];
int num = fos.read(buf);
while(num != (-1))
{
&nb
Ïà¹ØÎĵµ£º
ÔÚÓ¦ÓÃÖУ¬ÎÒÃdz£³£ÐèÒªThread»º³å³ØÀ´×öһЩÊÂÒÔÌá¸ß³ÌÐòµÄЧÂʺͲ¢·¢ÐÔ¡£±¾ÎÄÑÝʾÁËÈçºÎÀûÓÃQueueÕâÖÖÊý¾Ý½á¹¹ÊµÏÖÒ»¸ö¼òµ¥µÄThread»º³å³Ø¡£
Ò»¸öThread»º³å³Ø¿ÉÒÔÉè¼Æ³ÉÒÔÏÂÕâÑù£º»º³å³ØÓɼ¸¸ö¹¤×÷ThreadºÍÒ»¸öQueue×é³É£¬Client¸ºÔð°ÑÈÎÎñ·Åµ½QueueÀïÃ棨put·½·¨£©£¬¶ø¹¤×÷Thread¾ÍÒÀ´ÎÈ¡³öÕâЩÈÎÎñ²¢Ö´ÐÐËüÃÇ£¨get· ......
ÔÚjdk1.2ÖУ¬·Ö±ðÕë¶ÔJcomponentºÍTextÀàµÄ¶ÔÏó¶¨ÖÆÁ˲»Í¬µÄ´¦Àí¼üÅÌʼþµÄ·½·¨£ºÔÚJcomponentÖУ¬¶¨ÒåÁËregisterKeyboardAction·½·¨£¬Ê¹ÓÃÕâ¸ö·½·¨À´½«ÐèÒª´¦ÀíµÄ¼üÅÌʼþÒÔ¼°´¦ÀíʼþµÄÐÐΪ°ó¶¨ÔÚÒ»Æð¡£TextÀàÖоßÓÐkeymap¶ÔÏó£¬Í¬JcomponentÖеĴ¦Àí·½·¨ÀàËÆ£¬Õâ¸ö¶ÔÏó±£´æ×ÅÐèÒª´¦ÀíµÄ¼üÅÌʼþºÍ¶ÔÓ¦µÄÐÐΪ¡£
¡¡¡¡¶ø ......
1. Ò»¸öjavaÔ´ÎļþÖ»ÓÐÒ»¸öpublicÀàÇÒÀàÃûÓëÎļþÃûÒ»Ö¡£×¢£ºÒ»¸ö¿ÉÔËÐеÄjavaÓ¦ÓóÌÐòÓ¦ÓÐÒ»¸ömain·½·¨£¬ÇÒ¸ñʽ¹Ì¶¨£¬µ«²»Ò»¶¨ÔÚpublicÀàÖС£
2. packageÓï¾äÖ»ÄÜÓÐÒ»¸öÇÒ·ÅÔÚ³ÌÐòµÄµÚÒ»ÐС£
3. ÕûÊýÔÚÄÚ´æÖÐʽ°´ÕÕÆä²¹ÂëÀ´´æ´¢µÄ£¬ÕýÊýµÄ²¹Âë=ÔÂ룬¸ºÊýµÄ²¹Âë=ÔÂëÈ¡·´¼Ó1 £¬charÎÞ·ûºÅ루0~65535£©
4. Ç¿ÖÆ ......
¸Ã´úÂëʵÏÖÁËÔÚϵͳÓÒϽǵÄÈÎÎñÀ¸ÖÐÏÔʾ³ÌÐòµÄͼ±ê£¬²¢ÇÒ×îС»¯³ÌÐòºóµ¥»÷ͼ±ê¿ÉÒÔÏÔʾ³öÀ´Õâ¸ö³ÌÐò´°¿Ú
import java.awt.Color;
¡¡¡¡import java.awt.Image;
¡¡¡¡import java.awt.MenuItem;
¡¡¡¡import java.awt.PopupMenu;
¡¡¡¡import java.awt.Toolkit;
¡¡¡¡
¡¡¡¡
¡¡¡¡import javax.swing.JFrame;
¡¡¡ ......
1 »ù±¾·½·¨
import java.io.*;
public class input1
{
public static void main(String[] args) throws IOException
{
InputStreamReader reader = new InputStreamReader(System.in);
BufferedReader buf = new BufferedReader(reader);
/* »òÕß
BufferedReader buf; ......