exampleOne
This
package chario;
import java.util.Scanner;
import java.io.*;
//public class Chario {
// public static void main(String[] args) throws IOException
{
File file1 = new File("fileOne.txt"); //Create a reference to the physical file
/*
Use Notepad to create a text file named fileOne.txt
which must be in the same directory that src is in
To find src, open your project in NetBeans and hover its name, which is in
the top left just below the Projects menu; this will display the path to your project
My project path is, yours will be different
I:\\Ajava\161\WPPractice\IO\charstream\chario
My fileOne.txt is located in chario
*/
Scanner getit = new Scanner( file1 );
// connect a Scanner to the file int num, square;
num = getit.nextInt();
square = num * num ;
System.out.println("The square of " + num + " is " + square);
getit.close(); //Close the stream
}
}
/*
This is not part of your Java code but the file your code will read Your path will be different from mine.
Create fileOne.txt in
I:\\Ajava\161\WPPractice\IO\charstream\chario
Type an integer, 3, for example
Save fileOne.txt
Execute your program from NetBeans
*/
Note:- Study this program and follow the given instruction and type execute the code and also give output for this java program as soon as possible.
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images
- JAVA Programmingarrow_forwardIf wrong answer this time will downvote it Create a class with a static main that tests the ability to resolve and print a Path: • Create an instance of a FileSystem class. • Resolve an instance of a Path interface from a directory path and filename. • Print the constructed Path with System.out.println() method. 2. Create a class with a static main that tests the ability to resolve and print a Path: • Create an array of Path class. • Instantiate instances of Path with absolute and relative paths. • Print the constructed elements of the array of Path class with System.out.println() method. 3. Create a class to test serialisation class that implements serializable, it should implement the following: • A static void method that serialises an object. • A static void method that deserializes an object. • A static main method that tests the two by moving an object from one to the otherarrow_forwardThe file Names.txt is located in the folder input_files within your project. The content of that file is shown in the following figure Java: import java.io.FileInputStream;import java.io.FileNotFoundException;import java.util.ArrayList;import java.util.Scanner;public class Question2 {public static void main(String[] args) throws FileNotFoundException {/*** Part a* Finish creating an ArrayList called NameList that stores the names in the file Names.txt.*/ArrayList<String> NameList;/*** Part b* Replace null on the right-hand-side of the declaration of the FileInputStream object named inputStream* so that it is initialized correctly to the Names.txt file located in the folder specified in the question description*/FileInputStream inputStream = null;Scanner scnr = new Scanner(inputStream); //Do not modify this line of code/*** Part c* Using a loop and the Scanner object provided, read the names from Names.txt* and store them in NameList created in Part a.*//*** Part d* Reorder the…arrow_forward
- Write a program (in Java or C++), allowing to: • Create a folder "Main" • Create a file in the folder "File1" Add Read, Write permissions to "File1" Write in "File1" ● ● Read the content of "File1" ● Modify the content of "File1" Remove the Write permission of "File1" Try to write again in "File1" ● A screenshot is needed showing the results of the program execution.arrow_forwardJava programming 1. Write the code to print out an individual customer’s information. Your code must read the customer from a file, populate the object, and display the data from the object. Customer customer = new Customer (); 2. Write the signature line for this method 3, Write the line of code to read a line from the file Assume the object has been populated with the proper values. Write the line of code that will print one of the properties in the customer object. Be sure to include a textual description, e.g. “Customer Name: “arrow_forwardAssessment Description Honors Students: Complete this assignment according to the directions provided in the "Honors Addendum," located in Class Resources. This activity has multiple parts. All parts must be completed prior to documentation submission. Part 1: Reading and Writing Text Files. In this activity, you will learn how to read and write text files using non buffered and buffered File I/O classes, then learn how to parse a String into tokens using the String split() method, and finally, how to handle exceptions using various approaches. Part 2: Reading and Writing JSON Files. In this activity, you will learn how to read, write, and serialize JSON files to and from Java Objects. Refer to the instructions within "Activity 4 Guide" to complete the assignment. APA style is not required, but solid academic writing is expected. This assignment uses a rubric. Please review the rubric prior to beginning the assignment to become familiar with the expectations for successful…arrow_forward
- Question 1 Write a Java program that prompts the user to enter a file name. Then the program counts and displays the number of letters and words in the file. You may use the following code fragment to extract and count the letters and words. int charchterCounter - 0; int wordsCounter - 0; String line; Scanner fileContent while (fileContent.hasNext ()) { line = fileContent.nextLine (); if(line.trim ().length () > 0) wordsCounter = wordsCounter + line. split (" ").length; for (int i - 0; i < line.length (): i++) if (Character.isLetter (line.charAt (i))) charchterCounter++arrow_forwardJava : Create a .txt file with 3 rows of various movies data of your choice in the following table format: Movie ID number of viewers rating release year Movie name 0000012211 174 8.4 2017 "Star Wars: The Last Jedi" 0000122110 369 7.9 2017 "Thor: Ragnarok" Create a class Movie which instantiates variables corresponds to the table columns. Implement getters, setters, constructors and toString. Implement 2 readData() methods : the first one will return an array of Movies and the second one will return a List of movies . Test your methods.arrow_forwardT5arrow_forward
- 1.Problem Description Student information management system is used to input, display student information records. 1. The GUI interface for inputing ia designed as follows: The top part are the student imformation used to input student information, and the bottom part are four buttonns, 2. each button meaning: 3. (2) Total: add java score and C++ score, and display the result; 4. (3) Save: save student record into file named student.dat; 5. (4) Clear: set all fields on GUI to empty string: 6. (5) Close: close the window of GUI Student ID: Java Score: Note: Total Student ID: BC501 Java Score: 80 Note: He study java hard. Total Student Management System Student name: C++ Score: Save C++ Score: 90.5 Student Management System Student name: ALVIN CARM Save Total scores: Clear Sex Clear D E Male Female Close Sex Male Female Total scores: 170.5 Closearrow_forwardcreateDatabaseOfProfiles(String filename) This method creates and populates the database array with the profiles from the input file (profile.txt) filename parameter. Each profile includes a persons' name and two DNA sequences. 1. Reads the number of profiles from the input file AND create the database array to hold that number profiles. 2. Reads the profiles from the input file. 3. For each person in the file 1. creates a Profile object with the information from file (see input file format below). 2. insert the newly created profile into the next position in the database array (instance variable).arrow_forwardfile operator code 1 // The FileOperator class that includes methods for file input and output 2 // Your name 3 import java.io.*; 4 public class FileOperator 5 { 6 // instance variables 7 private File m_file; 8 9 // constructor 10 // Do not make any changes to this method! 11 public FileOperator() 12 { 13 String fileName = "employeeData.txt"; 14 m_file = new File(fileName); 15 } 16 17 // This method writes an array of Employees into a physical file. 18 // Each line is in this format: "S-Optimus Prime-Computer Science-$1200" 19 // "S" represents StudentWorker ("F" represents Faculty) 20 public void writeFile(Employee[] employees) 21 { 22 // TODO: implement this method 23 } 24 }arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education