创建ftp用户名和密码,其实就在ftp服务器的用户文件里面添加条记录。
卫辉网站建设公司创新互联,卫辉网站设计制作,有大型网站制作公司丰富经验。已为卫辉成百上千提供企业网站建设服务。企业网站搭建\成都外贸网站制作要多少钱,请找那个售后服务好的卫辉做网站的公司定做!
方法有两种,我说下思路。
一、你可以用java程序找到相应的配置文件,打开、把用户名密码写入进去。ok了。
二、你用用java程序调用创建ftp用户的命令,来创建ftp用户。
源程序如下:
import java.awt.Button;
import java.awt.GridLayout;
import java.awt.Panel;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
public class LoginValidation extends JFrame implements ActionListener{
private Panel pan = new Panel();
private Button login = new Button("login");
private TextField username = new TextField(10);
private JLabel opl1 = new JLabel("please login with username");
public LoginValidation() {
super("Login");
initialize();
}
public void initialize() {
this.setLayout(null);
this.setSize(360, 200);
this.setResizable(false);
this.add(pan);
pan.setBounds(10, 10, 330, 250);
pan.setLayout(new GridLayout(5, 1));
pan.add(opl1);
pan.add(username);
login.addActionListener(this);
pan.add(login);
this.setVisible(true);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource()==login){
String str = username.getText().trim();
if(str.equals("")|| str.equals(null))
{
JOptionPane.showMessageDialog(null,"username can be empty!!","username",JOptionPane.ERROR_MESSAGE);
return;
}
Pattern pt = Pattern.compile("^\\d{10}$");
Matcher m = pt.matcher(str);
if(m.matches()){
char c = str.charAt(0);
if(String.valueOf(c).equals("0")){
JOptionPane.showMessageDialog(null,"the first number can't be 0!!!","username",JOptionPane.ERROR_MESSAGE);
username.setText("");
repaint();
return;
}
else{
JOptionPane.showMessageDialog(null,"login success!!!","username",JOptionPane.INFORMATION_MESSAGE);
}
}
else{
JOptionPane.showMessageDialog(null,"username must be 10 numbers!!","username",JOptionPane.ERROR_MESSAGE);
username.setText("");
repaint();
}
}
}
public static void main(String[] args) {
new LoginValidation();
}
}
import java.util.Scanner;
public class Logon {
private static final char username = '青';
private static final int password = 123;
private static final Scanner san = new Scanner(System.in);
public static void main(String[] args) {
char iname;
int ipass;
System.out.print("请输入用户名: ");
iname = san.next().charAt(0);
System.out.print("请输入密码: ");
ipass = san.nextInt();
if(Logon.username == iname Logon.password == ipass) {
System.out.println("欢迎你, " + Logon.username);
} else {
System.out.println("对不起, 你不是" + Logon.username);
}
}
}
分析需求
输入 :John Smith
输出:JSmith
John是常用人名. Smith是姓氏. 中间使用空白分开
主要考查的字符串的操作
参考代码
import java.util.Scanner;
public class NameDemo {
public static void main(String[] args) {
System.out.println("请输入名字:");
Scanner sc = new Scanner(System.in);
String name = sc.nextLine().trim();
String[] ss = name.split("\\s+");// \s表示用空白切割字符串, +表示1个或者多个空白
String ming = ss[0];//名
String xing = ss[1];//姓
System.out.println(ming.charAt(0)+xing);// ming.charAt(0)表示取得该字符串的第一个字符
}
}
运行测试
请输入名字:
John Smith
JSmith