Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.01 KB | None | 0 0
  1. import java.io.*;
  2.  
  3. class LastFM {
  4.     static String sessionkey = "";
  5.     static String username = "";
  6.     static String password = "";
  7.    
  8.     public static void main(String[] args) {
  9.         if(args.length < 3) {
  10.             System.out.println("Error: not enough args!");
  11.             return;
  12.         }
  13.         readConfig("lastfm_config.txt");
  14.         System.out.println("lastfm username: " + username + ", password: " + doAskterisks(password.length));
  15.     }
  16.  
  17.     private static String doAskterisks(int len) {
  18.         String ob = "";
  19.         for(int i = 0; i < len; i++) {
  20.             ob += "*";
  21.         }
  22.         return ob;
  23.     }
  24.  
  25.     private static void readConfig(String file) {
  26.         BufferedReader in = null;
  27.         try {
  28.             in = new BufferedReader(new FileReader(file));
  29.             username = in.readLine();
  30.             password = in.readLine();
  31.         } catch(java.io.IOException e) {
  32.             System.err.println("Caught java.io.IOException: " + e.getMessage());
  33.         } finally {
  34.             if(in != null) {
  35.                 try {
  36.                     in.close();
  37.                 } catch(java.io.IOException e) {
  38.                     System.err.println("Caught java.io.IOException: " + e.getMessage());
  39.                 }  
  40.             }
  41.         }
  42.     }
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement