Java 类java.util.Scanner 实例源码

项目:android-dev-challenge    文件:NetworkUtils.java   
/**
 * This method returns the entire result from the HTTP response.
 *
 * @param url The URL to fetch the HTTP response from.
 * @return The contents of the HTTP response.
 * @throws IOException Related to network and stream reading
 */
public static String getResponseFromHttpUrl(URL url) throws IOException {
    HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
    try {
        InputStream in = urlConnection.getInputStream();

        Scanner scanner = new Scanner(in);
        scanner.useDelimiter("\\A");

        boolean hasInput = scanner.hasNext();
        if (hasInput) {
            return scanner.next();
        } else {
            return null;
        }
    } finally {
        urlConnection.disconnect();
    }
}
项目:Hacktoberfest-Data-Structure-and-Algorithms    文件:Closest.java   
public static void main(String[] args) {
    //get input
    Scanner sc = new Scanner(System.in).useDelimiter(" ");
    ArrayList<Integer> input = new ArrayList<>();
    //add input to ArrayList
    while (sc.hasNextInt()) {
        input.add(sc.nextInt());
    }
    //sort the list
    Collections.sort(input);
    //initialize closest values, with the first two elements in the list
    int closest = input.get(1)-input.get(0);
    //check all elements in the list
    for(int i = 2; i < input.size(); i++) {
        //change closest if we find two elements with a shorter distance.
        closest = Math.min(closest, input.get(i)-input.get(i-1));
    }
    //print the shortest distance
    System.out.println(closest);
}
项目:Shield    文件:Functions.java   
public static ArrayList<String[]> secondList(){

        try{
            Scanner scannerSongs = new Scanner(new File("Recommended_db.csv"));
            ArrayList<String[]> allSongs = new ArrayList<>();
            scannerSongs.nextLine();
            while (scannerSongs.hasNextLine()) {
                String line = scannerSongs.nextLine();
                String[] columns = line.split(",");
                String[] songInfo = {columns[3],columns[4],null};
                allSongs.add(songInfo);
            }
            return allSongs;

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        return null;
    }
项目:3way_laboratorios    文件:Ex4.java   
public static void main(String[] args) {
    // entrada = 3 notas
    // Seria o prompt do java script
    Scanner sc = new Scanner(System.in);
    System.out.println("Digite o valor da nota 1:");
    double nota1 = sc.nextDouble();
    System.out.println("Digite o valor da nota 2:");
    double nota2 = sc.nextDouble();
    System.out.println("Digite o valor da nota 3:");
    double nota3 = sc.nextDouble();

    // processamento = calcular media
    double media = (nota1 + nota2 + nota3)/3;

    // saida = condicao do aluno (Reprovado, aprovado, recuperacao)
    if (media <= 5) {
        System.out.println("Reprovado");
    } else if (media > 5 && media < 7) {
        System.out.println("Recuperacao");
    } else {
        System.out.println("Aprovado");
    }
}
项目:ecam-app-android    文件:NetworkUtils.java   
public static String getResponseFromHttpUrl(String url) throws IOException {

        URL urlObject = new URL(url);

        HttpURLConnection urlConnection =
                (HttpURLConnection) urlObject.openConnection();

        try {
            InputStream in = urlConnection.getInputStream();

            Scanner scanner = new Scanner(in);
            scanner.useDelimiter("\\A");

            boolean hasInput = scanner.hasNext();
            if (hasInput) {
                return scanner.next();
            } else {
                return null;
            }
        } finally {
            urlConnection.disconnect();
        }
    }
项目:AlgoCS    文件:FlatSpots_1617.java   
public static void main(String[] args) {
    Scanner x = new Scanner(System.in);
    PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));
    int n = x.nextInt(), c;
    int a[] = new int[701];
    for (int i = 0; i < n; i++) {
        c = x.nextInt();
        a[c]++;
    }
    int s = 0;
    for (int i = 600; i < a.length; i++) {
        s += a[i] / 4;
    }
    writer.print(s);
    writer.close();
}
项目:AlgoCS    文件:Stripies_1161.java   
public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    Byte n = in.nextByte();
    double ans = 0;
    double a[] = new double[n];
    for (int i = 0; i < a.length; i++) {
        a[i] = in.nextInt();
    }
    Arrays.sort(a);
    ans = a[a.length - 1];
    for (int i = a.length - 1; i > 0; i--) {
        ans = Max(ans, a[i - 1]);
    }
    System.out.printf("%.2f", ans);
}
项目:time4sys    文件:NfpFactoryImpl.java   
/**
 * @generated NOT
 */
@Override
public TimeInterval createTimeIntervalFromString(final String value) {
    final TimeIntervalImpl anInterval = new TimeIntervalImpl();
    final Scanner scan = new Scanner(value);
    final String leftPar = scan.findInLine("\\]|\\[");
    anInterval.setMinOpen("]".equals(leftPar));
    final String leftStr = scan.findInLine("[^,]*");
    anInterval.setMin(createDurationFromString(leftStr));
    scan.findInLine(",");
    String rightStr = scan.findInLine("[^\\]\\[]*");
    if (rightStr == null) {
        rightStr = leftStr;
    }
    anInterval.setMax(createDurationFromString(rightStr));
    final String rightPar = scan.findInLine("\\]|\\[");
    anInterval.setMaxOpen("[".equals(rightPar));
    scan.close();
    return anInterval;
}
项目:android-dev-challenge    文件:NetworkUtils.java   
/**
 * This method returns the entire result from the HTTP response.
 *
 * @param url The URL to fetch the HTTP response from.
 * @return The contents of the HTTP response, null if no response
 * @throws IOException Related to network and stream reading
 */
public static String getResponseFromHttpUrl(URL url) throws IOException {
    HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
    try {
        InputStream in = urlConnection.getInputStream();

        Scanner scanner = new Scanner(in);
        scanner.useDelimiter("\\A");

        boolean hasInput = scanner.hasNext();
        String response = null;
        if (hasInput) {
            response = scanner.next();
        }
        scanner.close();
        return response;
    } finally {
        urlConnection.disconnect();
    }
}
项目:codeforces    文件:Problem_427A.java   
public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int number = in.nextInt();

    int reserve = 0;
    int result = 0;
    int temp;
    for (int i = 0; i < number; i++) {
        temp = in.nextInt();
        if (temp == -1 && reserve > 0)
            reserve--;
        else if (temp == -1 && reserve == 0)
            result++;
        else if (temp > 0)
            reserve += temp;
    }

    System.out.print(result);
}
项目:MMORPG_Prototype    文件:GameServer.java   
private void startCommandHandlerOnNewThread()
{
    Log.info("NOTE: you can now type commands here.");
    CommandHandler commandHandler = new CommandHandler();
    Runnable commandHandlingTask = () ->
    {
        try (Scanner scanner = new Scanner(System.in))
        {
            while (true)
            {
                String command = scanner.nextLine();
                commandHandler.handle(command);
            }
        }
    };
    new Thread(commandHandlingTask).start();
}
项目:openjdk-jdk10    文件:FcFontConfiguration.java   
/**
 * Gets the OS version string from a Linux release-specific file.
 */
private String getVersionString(File f){
    try {
        Scanner sc  = new Scanner(f);
        return sc.findInLine("(\\d)+((\\.)(\\d)+)*");
    }
    catch (Exception e){
    }
    return null;
}
项目:codeforces    文件:Problem_591A.java   
public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int length = in.nextInt();
    int speed1 = in.nextInt();
    int speed2 = in.nextInt();

    double time = (double) length / (speed1 + speed2);
    System.out.print(time * speed1);
}
项目:teamcity-autotools-plugin    文件:DejagnuTestsXMLParser.java   
/**
 * Handles Xml file and public dejagnu test results from this.
 *
 * @param xmlFile file with test results
 * @return count of public xmlFile has been handled
 */
int handleXmlResults(@NotNull final File xmlFile){
  myTestsCount = 0;
  try {
    String xmlEntry = new Scanner(xmlFile, "UTF-8").useDelimiter("\\A").next();
    if (myNeedReplaceApm){
      xmlEntry = replaceAmp(replaceXmlHeaderVersion(xmlEntry));
    }
    if (myNeedToReplaceControls){
      xmlEntry = replaceControlChars(xmlEntry);
    }
    parseXmlTestResults(xmlEntry, xmlFile.getAbsolutePath());
    return myTestsCount;
  }
  catch (final FileNotFoundException ignored){
    //e.getMessage();
    return 0;
  }
}
项目:MyCourses    文件:stringVeriAlma.java   
public static void main(String [] args)
{
    Scanner input = new Scanner(System.in);
    int sayi;
    String metin;

/*
    system.out.println("Randevu adi giriniz : ");
    metin = input.next();
    system.out.println("Randevu yeri giriniz : ");
    metin = input.nextLine();
    system.out.print("Randevu tarih-saati giriniz : " + metin);
    sayi = input.nextLine();

    System.out.println("Randevunuz = " + randevu);
    System.out.println("Yeriniz = " + yer);
    System.out.println("Tarihiniz = " + tarih);


    getchar();
    return 0;
*/



}
项目:java_mooc_fi    文件:GreaterNumber.java   
public static void main(String[] args) {
    Scanner reader = new Scanner(System.in);

    System.out.print("Type the first number: ");
    int firstNumber = Integer.parseInt(reader.nextLine());
    System.out.print("Type the second number: ");
    int secondNumber = Integer.parseInt(reader.nextLine());

    System.out.println("");
    if ( firstNumber > secondNumber ) {
        System.out.println("Greater number: " + firstNumber);
    } else if (firstNumber < secondNumber) {
        System.out.println("Greater number: " + secondNumber);
    } else {
        System.out.println("The numbers are equal!");            
    }

}
项目:i_stolbov    文件:OracleClient.java   
/**
 * init.
 * @param socket - ip
 * @throws IOException - IOException
 */
public void init(Socket socket) throws IOException {
    String message;
    PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
    BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
    Scanner console = new Scanner(System.in);
    do {
        message = console.nextLine();
        out.println(message);
        String str;
        if (!EXIT.equals(message)) {
            while (!(str = in.readLine()).isEmpty()) {
                System.out.println(str);
            }
        }
    } while (!EXIT.equals(message));
}
项目:LivroJavaComoProgramar10Edicao    文件:AccountTest.java   
public static void main(String[] args)
{ 
   // create a Scanner object to obtain input from the command window
   Scanner input = new Scanner(System.in);

   // create an Account object and assign it to myAccount
   Account myAccount = new Account(); 

   // display initial value of name (null)
   System.out.printf("Initial name is: %s%n%n", myAccount.getName());

   // prompt for and read name
   System.out.println("Please enter the name:");
   String theName = input.nextLine(); // read a line of text
   myAccount.setName(theName); // put theName in myAccount
   System.out.println(); // outputs a blank line

   // display the name stored in object myAccount
   System.out.printf("Name in object myAccount is:%n%s%n",
      myAccount.getName());
}
项目:Homework    文件:Menu.java   
public static void main(String[] args)
{
    Scanner sc =new Scanner(System.in);
    System.out.println("************登录菜单************\n1、登录系统\n2、退出");
    int a1 = sc.nextInt();
    if(a1 == 1)
    {
        System.out.println("************主菜单************\n"
                + "1、客户管理系统\n2、购物结算\n3、真情回馈\n4、注销");
        int a2 = sc.nextInt();
        switch(a2)
        {
            case 1: 
                System.out.println("购物管理系统>客户信息管理\n"
                        + "1、显示所有客户信息\n2、添加客户信息\n3、修改客户信息\n4、查询客户信息");
                break;
            case 2: break;
            case 3:
                System.out.println("购物管理系统>真情回馈\n"
                        + "1、幸运大放送\n2、幸运抽奖\n3、生日问候");
                break;
            case 4: break;
        }
    }
    sc.close();
}
项目:codeforces    文件:Problem_379A.java   
public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int newCandle = in.nextInt();
    int oldCandle = in.nextInt();

    int hours = newCandle;
    int temp, remainder;

    temp = newCandle / oldCandle;
    remainder = newCandle % oldCandle;
    while (temp > 0) {
        hours += temp;
        newCandle = temp + remainder;
        temp = newCandle / oldCandle;
        remainder = newCandle % oldCandle;
    }
    System.out.print(hours);
}
项目:Stork    文件:InvQuadRegression.java   
public static void main(String[] args) {
  Scanner s = new Scanner(System.in);
  int num = 500000;

  // Test values
  double[] test_a = { 30, -40, 36 };

  //InvQuadRegression qr = new InvQuadRegression(list.size());
  InvQuadRegression qr = new InvQuadRegression(num);

  // Seed qr with random stuff.
  for (int i = 0; i < num; i++) {
    int n = (int) (15*Math.random())+1;
    double th = cal_thr(test_a, n);// + .1*Math.random();
    qr.add(n, 1/(th*th));
  }

  double[] a = qr.calculate();
}
项目:PatProject    文件:Prob1023.java   
public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = 10;
    int[] box = new int[n];
    box[0] = scanner.nextInt();
    boolean flag = false;
    for (int i = 1; i < n; i++) {
        box[i] = scanner.nextInt();
        if (!flag) {
            if (box[i] != 0) {
                System.out.print(i);
                box[i]--;
                flag = true;
            }
        }

    }
    for (int i = 0; i < n; i++) {
        if (box[i] != 0) {
            for (int j = 0; j < box[i]; j++) {
                System.out.print(i);
            }
        }
    }

}
项目:Homework    文件:OOex02.java   
public static void main(String[] args) 
{
    Scanner sc = new Scanner(System.in);
    Vistor vister = new Vistor();
    for (int i = 0; i < 10; i++) 
    {
        System.out.println("请输入姓名");
        vister.name = sc.next();
        if ("n".equals(vister.name)) 
        {
            System.out.println("退出程序");
            break;
        }
        System.out.println("请输入年龄");
        vister.age = sc.nextInt();
        vister.show();
    }

    sc.close();



}
项目:GitHub    文件:ComputerIdentifierGenerator.java   
private static String getWindowsIdentifier() throws IOException, NoSuchAlgorithmException {
    Runtime runtime = Runtime.getRuntime();
    Process process = runtime.exec(new String[] { "wmic", "csproduct", "get", "UUID" });

    String result = null;
    InputStream is = process.getInputStream();
    Scanner sc = new Scanner(process.getInputStream());
    try {
        while (sc.hasNext()) {
            String next = sc.next();
            if (next.contains("UUID")) {
                result = sc.next().trim();
                break;
            }
        }
    } finally {
        is.close();
    }

    return result==null?UNKNOWN:Utils.hexStringify(Utils.sha256Hash(result.getBytes()));
}
项目:robird-reborn    文件:TweetLongerUtils.java   
private static String readTweetLongedText(String id) {
    StringBuilder sb = new StringBuilder();
    try {
        Scanner scanner = new Scanner(new BufferedInputStream(
                new URL("http://www.twitlonger.com/api_read/" + id).openStream()));
        while (scanner.hasNext())
            sb.append(scanner.nextLine());
        scanner.close();
        return new TwitLongerResponse(sb.toString()).content;
    } catch (IOException e) {
        Timber.i("", e);
    }

    return sb.toString();
}
项目:Homework    文件:Discount.java   
public static void main(String[] args) 
{
    //从控制台输入会员积分
    Scanner sc = new Scanner(System.in);
    System.out.print("请输入会员积分:");
    int point = sc.nextInt();
    sc.close();
    //判断会员积分所属区间,输出相应折扣
    if (point < 2000)
    {
        System.out.println("该会员享受的的折扣是:9折");
    }
    else if (point < 4000)
    {
        System.out.println("该会员享受的的折扣是:8折");
    }
    else if (point < 8000)
    {
        System.out.println("该会员享受的的折扣是:7折");
    }
    else
    {
        System.out.println("该会员享受的的折扣是:6折");
    }   
}
项目:HackerRank_solutions    文件:Solution.java   
public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int t = scan.nextInt();
    for (int i = 0; i < t; i++) {
        try {
            long x = scan.nextLong();
            System.out.println(x + " can be fitted in:");
            if (x >= Byte.MIN_VALUE && x <= Byte.MAX_VALUE) {
                System.out.println("* byte");
            }
            if (x >= Short.MIN_VALUE && x <= Short.MAX_VALUE) {
                System.out.println("* short");
            }
            if (x >= Integer.MIN_VALUE && x <= Integer.MAX_VALUE) {
                System.out.println("* int");
            }
            if (x >= Long.MIN_VALUE && x <= Long.MAX_VALUE) {
                System.out.println("* long");
            }
        } catch (Exception e) {
            System.out.println(scan.next() + " can't be fitted anywhere.");
        }
    }
    scan.close();
}
项目:codeforces    文件:Problem_454A.java   
public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int size = in.nextInt();

    int middle = size / 2;
    for (int i = 0; i < size; i++) {
        for (int j = 0; j < size; j++) {
            if (i <= middle) {
                if (j <= middle + i && j >= middle - i)
                    System.out.print("D");
                else
                    System.out.print("*");
            } else {
                if (j <= size - (i - middle) - 1 && j >= i - middle)
                    System.out.print("D");
                else
                    System.out.print("*");
            }
        }
        System.out.println();
    }
}
项目:estrutura-de-dados    文件:Principal.java   
public static void main(String[] args) {
    Scanner leitor = new Scanner(System.in);
    Pilha pilha = new Pilha();
    String msg = "1 - Adiciona\n2 - Remove\n3 - Exibe\n9 - Sair";
    int opc, e;

    do {
        System.out.println(msg);
        opc = leitor.nextInt();

        switch (opc) {
            case 1:
                System.out.print("Elemento: ");
                e = leitor.nextInt();
                pilha.adiciona(e);
                break;
            case 2:
                System.out.println("Removido: " + pilha.remove());
                break;
            case 3:
                pilha.exibe();
                break;
        }
    } while(opc != 9);
}
项目:Java    文件:DriverFactorial.java   
public static void main(String []args)throws IllegalArgumentException
{
    Scanner sc=new Scanner(System.in);
    System.out.println("Enter a number whose fctorial need to be found");
    int x=sc.nextInt();
    long fac=0;
    try{
        if(x>20)
        throw new IllegalArgumentException(x);
        if(x<0)
        throw new IllegalArgumentException();
        fac=fact(x);
        System.out.println("Factorial of "+x+" is : "+fac);
    }
    catch(Exception e)                 /*For exceptions other than range specification*/
    {
        System.out.println(e);
        System.out.println("Factorial can't be calculated because of some exception.");
    }
}
项目:GitHub    文件:RealmTests.java   
private List<String> getCharacterArray() {
    List<String> chars_array = new ArrayList<String>();
    String file = "assets/unicode_codepoints.csv";
    Scanner scanner = new Scanner(getClass().getClassLoader().getResourceAsStream(file), "UTF-8");
    int i = 0;
    String currentUnicode = null;
    try {
        while (scanner.hasNextLine()) {
            currentUnicode = scanner.nextLine();
            char[] chars = Character.toChars(Integer.parseInt(currentUnicode, 16));
            String codePoint = new String(chars);
            chars_array.add(codePoint);
            i++;
        }
    } catch (Exception e) {
        fail("Failure, Codepoint: " + i + " / " + currentUnicode + " " + e.getMessage());
    }
    return chars_array;
}
项目:estrutura-de-dados    文件:Ex7.java   
public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    double radius, height, vol;

    System.out.print("Raio do Cilindro: ");
    radius = input.nextDouble();
    System.out.print("Altura do Cilindro: ");
    height = input.nextDouble();
    input.close();

    vol = (Math.PI * Math.pow(radius, 2)) * height;
    System.out.printf("Volume do Cilindro: %.2f\n", vol);
}
项目:java_mooc_fi    文件:PositiveValue.java   
public static void main(String[] args) {
    Scanner reader = new Scanner(System.in);

    // Type your program here:
    System.out.print("Type a number: ");
    int number = Integer.parseInt(reader.nextLine());

    System.out.println("");
    if (number > 0) {
        System.out.println("The number is positive.");
    } else {
        System.out.println("The number is not positive.");
    }

}
项目:azure-maven-plugins    文件:AddMojoTest.java   
@Test
public void assureInputFromUser() throws Exception {
    final AddMojo mojo = getMojoFromPom();
    final AddMojo mojoSpy = spy(mojo);
    final Scanner scanner = mock(Scanner.class);
    doReturn("2").when(scanner).nextLine();
    doReturn(scanner).when(mojoSpy).getScanner();

    final Set<String> set = new HashSet<>();
    mojoSpy.assureInputFromUser("property", "", Arrays.asList("a0", "a1", "a2"), set::add);

    assertTrue(set.contains("a2"));
}
项目:PatProject    文件:Prob1026.java   
public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long a = scanner.nextLong();
        long b = scanner.nextLong();
        long timeResult = Math.round((b - a) / 100.0);
        System.out.printf("%02d:%02d:%02d", timeResult / 3600, (timeResult / 60) % 60, timeResult % 60);
//        System.out.print(+":"++":"+);
    }
项目:HackerRank-in-Java    文件:Solution.java   
public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int m = scan.nextInt();
        int n = scan.nextInt();

        double [][] X = new double[n][m + 1];
        double [][] Y   = new double[n][1];

        for (int row = 0; row < n; row++) {
            X[row][0] = 1;
            for (int col = 1; col <= m; col++) {
                X[row][col] = scan.nextDouble();
            }
            Y[row][0] = scan.nextDouble();
        }

        /* Calculating B */
        double [][] xtx    = multiply(transpose(X),X);
        double [][] xtxInv = invert(xtx);
        double [][] xty    = multiply(transpose(X), Y);
        double [][] B      = multiply(xtxInv, xty);

        int sizeB = B.length;

        /* Calculating values for "q" feature sets */
        int q = scan.nextInt();
        for (int i = 0; i < q; i++) {
            double result = B[0][0];
            for (int row = 1; row < sizeB; row++) {
                result += scan.nextDouble() * B[row][0];
            }
            System.out.println(result);
        }

        scan.close();
    }
项目:hack    文件:TwoStrings.java   
public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int t = scanner.nextInt();

    for (int i = 0; i < t; i++) {
        int[] chars = new int[26];

        String a = scanner.next();

        String b = scanner.next();

        int n = a.length();
        if (n != b.length()) {
            System.out.println("NO");
        } else {
            for (int j = 0; j < n; j++) {
                chars[a.charAt(j) - 'a']++;
                chars[b.charAt(j) - 'a']--;
            }

            boolean found = true;

            for (int j = 0; j < 26; j++) {
                if (chars[j] != 0) {
                    System.out.println("NO");

                    found = false;

                    break;
                }
            }

            if (found) {
                System.out.println("YES");
            }
        }
    }
}
项目:Progetto-A    文件:PartitaOfflineConsoleView.java   
/**
 * 
 * @param model modello partita offline
 */
public PartitaOfflineConsoleView(PartitaOfflineModel model) {
    this.listeners = new CopyOnWriteArrayList<>();
    this.model = model;
    this.model.addObserver(this);
    scanner = new Scanner(System.in);
}
项目:Homework    文件:HibernateTest.java   
@Test
public void adoptPet()
{
    Scanner input = new Scanner(System.in);
    LOGGER.info("欢迎光临宠物乐园");
    LOGGER.info("请输入登录名:");
    String username = input.next();
    LOGGER.info("请输入密码:");
    String password = input.next();

    Master master = new Master(username, password);

    MasterDao mas = new MasterDaoImpl(session, tx);
    MasterServiceImpl masterService = new MasterServiceImpl(mas);
    if(masterService.login(master))
    {
        LOGGER.info("登录成功!");
        Pet pet = new Pet();
        pet.setName("旺财");
        pet.setMaster(master);
        PetType pt = new PetType();
        pt.setName("狗狗");
        session.persist(pt);
        pet.setPetType(pt);
        masterService.adoptPet(pet);
    }
    else 
    {
        LOGGER.info("登录失败!");
    }
}