Hello guys, welcome to the 26th session of the VA dot A tutorials for beginner. In this session we will see how to create the line for the pa da da by using the Java. For this I am going to use the IntelliJ IDEA and create a new project which does not require the any additional framework so click on the Next. Next and give the project name joe klein to for APA here is a project created. Here we need to add some Maven modules or the dependency. For right click on the project select the open module setting click on the plus sign library from Marvin Search for the APA Dotty a library select it and click on ok we need to download all of the classes then we need to add the dependency for the age decent search for it which was created by the a Google select and press OK download its class Samsung step will be performed on the those tomorrow add modules to after adding the dependencies to the air those for our end modules click OK x one the project and create a new Java class DNA program This will be the console application in which user can type the text on the console.
And we will send that text to the API dot Asian. For that we need to add the some packages. For java.io dot Trista bought a DOD, VA DOD to start as well as a.tpa.models.ca. Here I am added to all of the classes within the package you can also add the SM specific am going to create a main method public static void main string args within that create our instance of the BufferedReader reader portal BufferedReader within that we will pass the input stream reader, which will take the system.io and create an instance of the data service data race equal to new UI data service, which will take the new API configuration. Within that window, pass the api.ai token and the semicolon it then create a try catch block. I'm handling the any exception You can also handle the specific exception.
System dot out dot print ln accepts and or to get message and create an infinite loop while true India shouting we will display that user will write the attacks from here so we will write the you System dot out dot print you after that we waited for the airline that user was written string line equal to reader dot read line bang creator a request request equal to new a request. Within there Do we need to pass the line And by using the data services we can send the request which will return the a response response equal to and from the response we will check that any errors occur or not for that right Eve response dot, get status dot get code equals equal 200 means everything is okay. Then we need to write the System dot out dot print ln both responses days which will be the response.gov To result, the fulfillment or get the speech we will display the response.status.to get error details which contain the original error that occurs.
Let's run the project run the program.me here is the console come with a TextView and now I am writing the Hello here we got the hi Ted Now writing the sum of 80 and 50. Here we got the sum of 80 and 15, the 130. Let's see what we learn in this lesson. Here are the four mobile models that we are added in the our project for the dependency. And here is the method that we are created, in which we edited the text from the console by using the BufferedReader and use the data service to send the request to the API dot A. Like the other programming language, use the a request to the set the requested data and a response to obtain the responsibility.
Thanks for watching. Have a nice day.