Register   Login   About   Study   Enterprise   Share
Internet / AI Technology University (ITU/AITU)
Fast Login - available after registration







|

Top Links: Technology - Discussion >> Internet Technology Summit Program - Discussion >> 3. Threads and Network - Discussion >> 3.2. Network - Discussion
Current Topic: 3.3. Threads and network project - Discussion by Christopher Woodruff
You have a privilege to create a quiz (QnA) related to this subject and obtain creativity score...
3.3. Threads and network project - Discussion. Press COMMENTS to add your comments or questions.

Do you want to refresh your memory and read again the subject of discussion? Right Here!.
| Check Your Progress | Propose QnA | Have a question or comments for open discussion?
Comments
2017-07-28_15:54 by Christopher Woodruff
There are few things to point out here. First, YouTube uses '+' for separating search words. So, a search may look like http://www.youtube.com/results?search_query=Red+vs+Blue We have to make sure the user is able to naturally enter a search term with more than one word and have that entered into the end of the given URL correctly. Second, I believe that the wait() timer gets placed into the code to allow the HTML to be written for the file. In other words: Create the new html, YouTube loads the page; take the html code from THAT page; save it into a file; give the computer/internet enough time to copy-paste the code; program should terminate after. I'm not going to show the full code used, but here's a snippet to help:
/**
	 * The fileWriter() method creates a file of any writable type (text, html, etc) and
	 * places it into the desired directory with the given file name. It takes a String
	 * argument as the data to be input into the file. This method is intended to be
	 * flexible for future use. 
	 * 
	 * @param path The file's destination path (Ex: C:/myfolder/) The last forward slash
	 * (/) is necessary. It will be combined with the file name to get the final location-
	 * name combination.
	 * @param fileName The name of the file including the extension. (Ex: myWebPage.html)
	 * @param data Any data to be passed into the file. This is meant to be text based
	 * data only.
	 * @throws IOException
	 * @throws InterruptedException 
	 */
	public synchronized void fileWriter(String path, String fileName, String data) throws IOException{
		BufferedWriter bw = new BufferedWriter(new FileWriter(path + fileName));

		try {
			...write the data into the file
			notify();
		}
		catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * Get input from the user using Scanner and pass it through the other methods to
	 * eventually output a HTML file.
	 */
	public synchronized void run(){
		...use WbPageReader class
		readKeyword();
		
		try {
			...send the information to the fileWriter() method.
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println("Check your file."); //Just a friendly message to let them know when it's done.
	}
Notice both of those methods were not 'static' but 'synchronized'. This is necessary to use the notify() and wait() methods.
/**
	 * The fileWriter() method creates a file of any writable type (text, html, etc) and
	 * places it into the desired directory with the given file name. It takes a String
	 * argument as the data to be input into the file. This method is intended to be
	 * flexible for future use. 
	 * 
	 * @param path The file's destination path (Ex: C:/myfolder/) The last forward slash
	 * (/) is necessary. It will be combined with the file name to get the final location-
	 * name combination.
	 * @param fileName The name of the file including the extension. (Ex: myWebPage.html)
	 * @param data Any data to be passed into the file. This is meant to be text based
	 * data only.
	 * @throws IOException
	 * @throws InterruptedException 
	 */
	public synchronized void fileWriter(String path, String fileName, String data) throws IOException{
		BufferedWriter bw = new BufferedWriter(new FileWriter(path + fileName));

		try {
			...write the data into the file
			notify();
		}
		catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * Get input from the user using Scanner and pass it through the other methods to
	 * eventually output a HTML file.
	 */
	public synchronized void run(){
		...use WbPageReader class
		readKeyword();
		
		try {
			...send the information to the fileWriter() method.
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println("Check your file."); //Just a friendly message to let them know when it's done.
	}


Notice both of those methods were not 'static' but 'synchronized'. This is necessary to use the notify() and wait() methods.

Have a suggestion? - shoot an email
Looking for something special? - Talk to me
Read: IT of the future: AI and Semantic Cloud Architecture | Fixing Education
Do you want to move from theory to practice and become a magician? Learn and work with us at Internet Technology University (ITU) - JavaSchool.com.

Technology that we offer and How this works: English | Spanish | Russian | French

Internet Technology University | JavaSchool.com | Copyrights © Since 1997 | All Rights Reserved
Patents: US10956676, US7032006, US7774751, US7966093, US8051026, US8863234
Including conversational semantic decision support systems (CSDS) and bringing us closer to The message from 2040
Privacy Policy