List of usage examples for java.util Scanner hasNextLine
public boolean hasNextLine()
From source file:la2launcher.MainFrame.java
private void scanSumFile(File sums, SumHandler handler, boolean full) throws FileNotFoundException, IOException { FileInputStream fis = new FileInputStream(sums); Scanner scn = new Scanner(fis); while (scn.hasNextLine()) { String line = scn.nextLine(); if ("#-[Required from required.ini]----------------------------------".equals(line)) { break; }/* ww w .ja va 2 s. c o m*/ int pipe = line.indexOf('|'); int nextPipe = line.indexOf('|', pipe + 1); String sum = line.substring(0, pipe); String name = line.substring(pipe + 1, nextPipe); if (!full) { if (name.toUpperCase().startsWith("\\SYSTEM")) { handler.handle(new MDNamePair(name, sum)); } } else { handler.handle(new MDNamePair(name, sum)); } } scn.close(); fis.close(); }
From source file:la2launcher.MainFrame.java
private int scanSumFilesCount(File sums, boolean full) throws FileNotFoundException, IOException { FileInputStream fis = new FileInputStream(sums); Scanner scn = new Scanner(fis); int lc = 0;// w w w. j ava 2s . com while (scn.hasNextLine()) { String line = scn.nextLine(); if ("#-[Required from required.ini]----------------------------------".equals(line)) { break; } int pipe = line.indexOf('|'); int nextPipe = line.indexOf('|', pipe + 1); String sum = line.substring(0, pipe); String name = line.substring(pipe + 1, nextPipe); if (!full) { if (name.toUpperCase().startsWith("\\SYSTEM")) { lc++; } } else { lc++; } } scn.close(); fis.close(); return lc; }
From source file:com.wwpass.connection.WWPassConnection.java
/** * <p>Calls to this function acquire a newly issued ticket from SPFE.</p> * * @return Ticket issued by the SPFE/*from w ww .j a va 2s . c o m*/ * @throws IOException * @throws WWPassProtocolException */ public String getTicket() throws IOException, WWPassProtocolException { HashMap<String, String> parameters = new HashMap<String, String>(); Scanner scanner = new Scanner(makeRequest("GET", "get", parameters)); StringBuilder sb = new StringBuilder(); while (scanner.hasNextLine()) { sb.append(scanner.nextLine()); } scanner.close(); return sb.toString(); }
From source file:com.wwpass.connection.WWPassConnection.java
/** * <p>Calls to this function check the authentication of the ticket.</p> * * @param ticket The ticket to validate. * @return Returns current ticket or newly issued ticket. The new ticket should be used in future * operations with the SPFE./*from ww w. ja va 2 s. co m*/ * @throws IOException * @throws WWPassProtocolException */ public String putTicket(String ticket) throws IOException, WWPassProtocolException { HashMap<String, String> parameters = new HashMap<String, String>(); parameters.put("ticket", ticket); Scanner scanner = new Scanner(makeRequest("GET", "put", parameters)); StringBuilder sb = new StringBuilder(); while (scanner.hasNextLine()) { sb.append(scanner.nextLine()); } scanner.close(); return sb.toString(); }
From source file:com.wwpass.connection.WWPassConnection.java
/** * <p>Gets an id of the user from the Service Provider Front End. This ID is unique for one * Service Provider, and different for different Service Providers.</p> * * @param ticket Ticket issued by the SPFE * * @return PUID issued by the SPFE//w w w . j a v a2 s.c om * @throws IOException * @throws WWPassProtocolException */ public String getPUID(String ticket) throws IOException, WWPassProtocolException { HashMap<String, String> parameters = new HashMap<String, String>(); parameters.put("ticket", ticket); Scanner scanner = new Scanner(makeRequest("GET", "puid", parameters)); StringBuilder sb = new StringBuilder(); while (scanner.hasNextLine()) { sb.append(scanner.nextLine()); } scanner.close(); return sb.toString(); }
From source file:com.wwpass.connection.WWPassConnection.java
/** * <p>Calls to this function acquire a newly issued ticket from SPFE.</p> * * @param auth_type Defines which credentials will be asked of the user to authorize this ticket. * Currently only two values supported: 'p': to ask for PassKey and password; empty string to ask * for PassKey only (default).// w w w .j a v a 2 s. c o m * @return Ticket issued by the SPFE * @throws IOException * @throws WWPassProtocolException */ public String getTicket(String auth_type) throws IOException, WWPassProtocolException { HashMap<String, String> parameters = new HashMap<String, String>(); parameters.put("auth_type", auth_type); Scanner scanner = new Scanner(makeRequest("GET", "get", parameters)); StringBuilder sb = new StringBuilder(); while (scanner.hasNextLine()) { sb.append(scanner.nextLine()); } scanner.close(); return sb.toString(); }
From source file:com.wwpass.connection.WWPassConnection.java
/** * <p>Calls to this function acquire a newly issued ticket from SPFE.</p> * * @param ttl The period in seconds for the ticket to remain valid since issuance. * The default value is 120 seconds.// ww w . java 2s.co m * @return Ticket issued by the SPFE * @throws IOException * @throws WWPassProtocolException */ public String getTicket(int ttl) throws IOException, WWPassProtocolException { HashMap<String, String> parameters = new HashMap<String, String>(); parameters.put("ttl", Integer.toString(ttl)); Scanner scanner = new Scanner(makeRequest("GET", "get", parameters)); StringBuilder sb = new StringBuilder(); while (scanner.hasNextLine()) { sb.append(scanner.nextLine()); } scanner.close(); return sb.toString(); }
From source file:com.wwpass.connection.WWPassConnection.java
/** * <p>Calls to this function check the authentication of the ticket.</p> * * @param ticket The ticket to validate. * @param auth_type Defines which credentials will be asked of the user to authorize this ticket. * Currently only two values supported: 'p': to ask for PassKey and password; empty string to ask * for PassKey only (default).//from www . j a v a2 s. c o m * @return Returns current ticket or newly issued ticket. The new ticket should be used in future * operations with the SPFE. * @throws IOException * @throws WWPassProtocolException */ public String putTicket(String ticket, String auth_type) throws IOException, WWPassProtocolException { HashMap<String, String> parameters = new HashMap<String, String>(); parameters.put("ticket", ticket); parameters.put("auth_type", auth_type); Scanner scanner = new Scanner(makeRequest("GET", "put", parameters)); StringBuilder sb = new StringBuilder(); while (scanner.hasNextLine()) { sb.append(scanner.nextLine()); } scanner.close(); return sb.toString(); }
From source file:com.wwpass.connection.WWPassConnection.java
/** * <p>Calls to this function check the authentication of the ticket.</p> * * @param ticket The ticket to validate. * @param ttl The period in seconds for the ticket to remain valid since issuance. The default * value is 120 seconds.// ww w . ja v a 2 s . c o m * @return Returns current ticket or newly issued ticket. The new ticket should be used in future * operations with the SPFE. * @throws IOException * @throws WWPassProtocolException */ public String putTicket(String ticket, int ttl) throws IOException, WWPassProtocolException { HashMap<String, String> parameters = new HashMap<String, String>(); parameters.put("ticket", ticket); parameters.put("ttl", Integer.toString(ttl)); Scanner scanner = new Scanner(makeRequest("GET", "put", parameters)); StringBuilder sb = new StringBuilder(); while (scanner.hasNextLine()) { sb.append(scanner.nextLine()); } scanner.close(); return sb.toString(); }
From source file:com.wwpass.connection.WWPassConnection.java
/** * <p>Calls to this function acquire a newly issued ticket from SPFE.</p> * * @param auth_type Defines which credentials will be asked of the user to authorize this ticket. * Currently only two values supported: 'p': to ask for PassKey and password; empty string to ask * for PassKey only (default)./*from w w w. ja v a2s . c o m*/ * @param ttl The period in seconds for the ticket to remain valid since issuance. The default * value is 120 seconds. * @return Ticket issued by the SPFE * @throws IOException * @throws WWPassProtocolException */ public String getTicket(String auth_type, int ttl) throws IOException, WWPassProtocolException { HashMap<String, String> parameters = new HashMap<String, String>(); parameters.put("auth_type", auth_type); parameters.put("ttl", Integer.toString(ttl)); Scanner scanner = new Scanner(makeRequest("GET", "get", parameters)); StringBuilder sb = new StringBuilder(); while (scanner.hasNextLine()) { sb.append(scanner.nextLine()); } scanner.close(); return sb.toString(); }