IoT CAS Frameworks/IOT_Server/License_Framework/LicenseKeyGenerator/src/com/prokosha/licensekeygenerator/ValidateKey.java
public static String[] readFile(String fileName) throws IOException {
		String key[] = new String[2];
		FileReader fr = new FileReader(fileName);
		BufferedReader br = new BufferedReader(fr);
		String lines;
		try {
			while ((lines = br.readLine()) != null) {
				String[] value = lines.split("=");
				if (lines.startsWith("key=") && key[0] == null) {
					if (value.length <= 1) {
						throw new IOException("Missing key information");
					} else {
						key[0] = value[1];
						System.out.println("key value here is " + key[0]);
					}
				}

				/*
				 * if (lines.startsWith("key2=") && key[1] == null) { if
				 * (value.length <= 1) { throw new
				 * IOException("Missing key2 information"); } else { key[1] =
				 * value[1]; System.out.println("key2 value here is " + key[1]);
				 * } }
				 */

				else
					continue;
			}
			String keyFromFile = key[0].toString();
			System.out.println("key from file is :" + keyFromFile);
			// String stringKey2 = key[1].toString();
			String szFinal1 = keyFromFile.substring(0, 16);
			System.out.println("In read final key method szFinal1 is "
					+ szFinal1);
			String szFinal2 = keyFromFile.substring(16, 32);
			System.out.println("In read final key method szFinal2 is "
					+ szFinal2);
			Validate_keys(szFinal1, szFinal2);

			// Validate_keys(stringKey1, stringKey2);

			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return key;
	}
// this method for reading keys from text file .....
this method for reading keys from text file
this method for reading keys from text file
public static String[] readFile(String fileName) throws IOException {
		String key[] = new String[2];
		FileReader fr = new FileReader(fileName);
		BufferedReader br = new BufferedReader(fr);
		String lines;
		try {
			while ((lines = br.readLine()) != null) {
				String[] value = lines.split("=");
				if (lines.startsWith("key=") && key[0] == null) {
					if (value.length <= 1) {
						throw new IOException("Missing key information");
					} else {
						key[0] = value[1];
						System.out.println("key value here is " + key[0]);
					}
				}
				/*
				 * if (lines.startsWith("key2=") && key[1] == null) { if
				 * (value.length <= 1) { throw new
				 * IOException("Missing key2 information"); } else { key[1] =
				 * value[1]; System.out.println("key2 value here is " + key[1]);
				 * } }
				 */
				else
					continue;
			}
			String keyFromFile = key[0].toString();
			System.out.println("key from file is :" + keyFromFile);
			String szFinal1 = keyFromFile.substring(0, 16);
			System.out.println("In read final key method szFinal1 is "
					+ szFinal1);
			String szFinal2 = keyFromFile.substring(16, 32);
			System.out.println("In read final key method szFinal2 is "
					+ szFinal2);
			Validate_keys(szFinal1, szFinal2);
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return key;
	}
public static String [ ] readFile ( String fileName ) throws IOException { String key [ ] = new String [ 2 ] ; FileReader fr = new FileReader ( fileName ) ; BufferedReader br = new BufferedReader ( fr ) ; String lines ; try { while ( ( lines = br . readLine ( ) ) != null ) { String [ ] value = lines . split ( "=" ) ; if ( lines . startsWith ( "key=" ) && key [ 0 ] == null ) { if ( value . length <= 1 ) { throw new IOException ( "Missing key information" ) ; } else { key [ 0 ] = value [ 1 ] ; System . out . println ( "key value here is " + key [ 0 ] ) ; } } /*
				 * if (lines.startsWith("key2=") && key[1] == null) { if
				 * (value.length <= 1) { throw new
				 * IOException("Missing key2 information"); } else { key[1] =
				 * value[1]; System.out.println("key2 value here is " + key[1]);
				 * } }
				 */ else continue ; } String keyFromFile = key [ 0 ] . toString ( ) ; System . out . println ( "key from file is :" + keyFromFile ) ; String szFinal1 = keyFromFile . substring ( 0 , 16 ) ; System . out . println ( "In read final key method szFinal1 is " + szFinal1 ) ; String szFinal2 = keyFromFile . substring ( 16 , 32 ) ; System . out . println ( "In read final key method szFinal2 is " + szFinal2 ) ; Validate_keys ( szFinal1 , szFinal2 ) ; br . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return key ; }
this method for reading keys from text file .....
this method for reading keys from text file .....
// String stringKey2 = key[1].toString(); // Validate_keys(stringKey1, stringKey2);