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
相关文档:
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列
......
Java NIO API详解
在JDK
1.4以前,Java的IO操作集中在java.io这个包中,是基于流的阻塞(blocking)API。对于大多数应用来说,这样的API使用很方
便,然而,一些对性能要求较高的应用,尤其是服务端应用,往往需要一个更为有效的方式来处理IO。从JDK 1.4起,NIO
API作为一个基于缓冲区,并能提供非阻塞(non-blo ......
1、不可以用一个本地类型(如int float)来替换泛型.比如List<Integer>不能用List<int>型式
2、运行时类型检查,不同类型的泛型类是等价的(Pair<String>与Pair<Employee>是属于同一个
类型 Pair),这一点要特别注意:即如果a instanceof
Pair<String>==true的话,并不代表a. ......
刚刚学习了继承,记录下我觉得继承中我们应该注意的问题. 什么继承是使用extends来实现的,这种问题记录下来是不是有点降低哥的IQ呢?哈哈,所以这些基础语法就不记录咯.下面开始吧:
1.在学习java中,我们应该要知道所有类的超类都是object类,这样说的意思就是说,所有的类都包含了 ......
对于Java桌面应用来说,比较烦琐的就是安装部署问题,如:客户端是否安装有jre、jre版本、jre在哪里下载、如何用jre启动Java应用等等。不要说刚接触电脑的人,就算是比较熟悉电脑,如果没有接触过Java,面对一个Java应用,如何在Windows下启动它,估计都会折腾半天。所以这个是导致Java桌面应用被一些人所讨厌的最大原因,J ......