Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String pass;
- String user;
- user = txtUser.getText();
- pass = txtPass.getText();
- if(pass.equals("blue") && user.equals("bob") ){
- lblDisplay.setText("Credentials Accepted.");
- }
- else{
- lblDisplay.setText("Please try again.");
- }
- import java.util.Scanner; // I use scanner because it's command line.
- public class Login {
- public void run() {
- Scanner scan = new Scanner (new File("the\dir\myFile.extension"));
- Scanner keyboard = new Scanner (System.in);
- String user = scan.nextLine();
- String pass = scan.nextLine(); // looks at selected file in scan
- String inpUser = keyboard.nextLine();
- String inpPass = keyboard.nextLine(); // gets input from user
- if (inpUser.equals(user) && inpPass.equals(pass)) {
- System.out.print("your login message");
- } else {
- System.out.print("your error message");
- }
- }
- }
- import java.util.Scanner;
- public class BATM {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- String username;
- String password;
- System.out.println("Log in:");
- System.out.println("username: ");
- username = input.next();
- System.out.println("password: ");
- password = input.next();
- //users check = new users(username, password);
- if(username.equals(username) && password.equals(password))
- System.out.println("You are logged in");
- }
- }
- import java.util.Scanner;
- public class LoginMain {
- public static void main(String[] args) {
- String Username;
- String Password;
- Password = "123";
- Username = "wisdom";
- Scanner input1 = new Scanner(System.in);
- System.out.println("Enter Username : ");
- String username = input1.next();
- Scanner input2 = new Scanner(System.in);
- System.out.println("Enter Password : ");
- String password = input2.next();
- if (username.equals(Username) && password.equals(Password)) {
- System.out.println("Access Granted! Welcome!");
- }
- else if (username.equals(Username)) {
- System.out.println("Invalid Password!");
- } else if (password.equals(Password)) {
- System.out.println("Invalid Username!");
- } else {
- System.out.println("Invalid Username & Password!");
- }
- }
- }
- String user;
- String pass;
- Scanner scan = new Scanner(new File("File.txt"));
- while(scan.hasNext){ //While the file still has more lines remaining
- if(scan.nextLine() == user){
- if(scan.nextLine == pass){
- lblDisplay.setText("Credentials Accepted.");
- }
- else{
- lblDisplay.setText("Please try again.");
- }
- }
- }
- import java.<span class="q39pbqr9" id="q39pbqr9_9">net</span>.*;
- import java.io.*;
- <span class="q39pbqr9" id="q39pbqr9_1">public class</span> A
- {
- static String user = "user";
- static String pass = "pass";
- static String param_user = "username";
- static String param_pass = "password";
- static String content = "";
- static String action = "action_url";
- static String urlName = "url_name";
- public static void main(String[] args)
- {
- try
- {
- user = URLEncoder.encode(user, "UTF-8");
- pass = URLEncoder.encode(pass, "UTF-8");
- content = "action=" + action +"&" + param_user +"=" + user + "&" + param_pass + "=" + pass;
- URL url = new URL(urlName);
- HttpURLConnection urlConnection = (HttpURLConnection)(url.openConnection());
- urlConnection.setDoInput(true);
- urlConnection.setDoOutput(true);
- urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
- urlConnection.setRequestMethod("POST");
- DataOutputStream dataOutputStream = new DataOutputStream(urlConnection.getOutputStream());
- dataOutputStream.writeBytes(content);
- dataOutputStream.flush();
- dataOutputStream.close();
- BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
- String responeLine;
- StringBuilder response = new StringBuilder();
- while ((responeLine = bufferedReader.readLine()) != null)
- {
- response.append(responeLine);
- }
- System.out.println(response);
- }catch(Exception ex){ex.printStackTrace();}
- }
Add Comment
Please, Sign In to add comment