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表示降序排列
......
编程:编写一个截取字符串的函数,输入为一个字符串和字节数,输出为按字节截取的字符串。但是要保证汉字不被截半个,如"我ABC"4,应该截为"我AB",输入"我ABC汉DEF",6,应该输出为"我ABC"而不是"我ABC+汉的半个"。
public static String substring(String str, int toCount,String& ......
1、不可以用一个本地类型(如int float)来替换泛型.比如List<Integer>不能用List<int>型式
2、运行时类型检查,不同类型的泛型类是等价的(Pair<String>与Pair<Employee>是属于同一个
类型 Pair),这一点要特别注意:即如果a instanceof
Pair<String>==true的话,并不代表a. ......
中国Java培训,尤其是北京的Java所谓高端培训,至少已经火了5年以上了,最近有一些想法和大家分享一下。
现在比较有名的Java培训有 达内,东方标准,尚学堂,传智博客,赛尔凯达,还有蓝点等等吧其他名气不怎么大了,对了还有北大青鸟 。
最早知道的是北大青鸟,上大学就知道这个了 ......