Here you can find the source of loadCredentials(File credentials)
Parameter | Description |
---|---|
credentials | Credentials file |
public static String[] loadCredentials(File credentials)
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; public class Main { /**/*from www . j a v a 2 s. c om*/ * Return the credentials in the file. * <ul> * <li>First line: user</li> * <li>Second line: plain password</li> * <li>Third line: token</li> * </ul> * * @param credentials * Credentials file * @return Credentials */ public static String[] loadCredentials(File credentials) { BufferedReader reader = null; String login = null; String password = null; String token = null; try { reader = new BufferedReader(new FileReader(credentials)); login = readLine(reader); password = readLine(reader); token = readLine(reader); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { if (reader != null) { reader.close(); } } catch (IOException e) { e.printStackTrace(); } } return new String[] { login, password, token }; } /** * Read a line from the reader * * @param reader * Reader * @return line from the reader * @throws IOException */ private static String readLine(BufferedReader reader) throws IOException { String line = reader.readLine(); if (line != null) { return line.trim(); } return null; } }