EBK JAVA PROGRAMMING
8th Edition
ISBN: 9781305480537
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 13, Problem 20RQ
<PROGRAM-DESCRIPTION-ANSWER>
A file channel “is seekable”.
Hence, the correct answer is option “C”.
</PROGRAM-DESCRIPTION-ANSWER>
Explanation of Solution
File Channel:
- A file channel is a SeekableByteChannel that is connected to a file. It has a current position within its file that can be both queried and modified.
- The file itself contains a variable-length sequence of bytes, which can be read and written and whose current size can be queried...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
I have a "user.json" file that looks like this
{
"something@somewhere.com": "maybe",
"john@beatles.uk": "lennonj!",
"paul@beatles.uk": "mccartney",
"mick@rollingstones.uk": "jaggerm!"
}
using java script i have to parse this file and then check this email and file conbinations against user input
This is the code i m using to parse the file.
function lookUpCredentials(filePath, cb) {
fs.readFile(filePath, (err, fileData) => {
if (err) {
return cb && cb(err);
}
try {
const object = JSON.parse(fileData);
return cb && cb(null, object);
} catch (err) {
return cb && cb(err);
}
});
}
lookUpCredentials("./user.json", (err, data) => {
if (err) {
console.log(err);
return;
}
credentials = data;
});
and this is the code i m using to get input from the user
app.post('/login', (req, res) => {
let username =…
Which of the following statements will write to an output file, assuming that a variable oFile has been declared correctly as in the previous question and that a String variable named s has been created with the appropriate data to write?
A
oFile.println(s);
B
oFile.write(s);
C
oFile.output(s);
D
oFile.fileWrite(s);
can someone check why my code is not working?
intergers.txt
4
7
2
5
3
#include <iostream>#include <fstream>using namespace std;
int main(){int num[100],i=-1; // variable declaration to read the integer data
char tx;//variable declared
ifstream myFile; // input file declaration
myFile.open("numbers.txt"); // Syntax for open the file and read integer.txt
while (!(myFile.eof())){ myFile >> num[i]; i++;
// read the integer content from the file
//myFile>>tx; // read the comma}num[i] = num[i+1]; // Delete the last garbage valuecout<<"The elements in the array are "; for(int j=0;j<i;j++){ // Loop to run for all the elements in the array if(j==i-1) cout<<num[j]<<endl; // print element with new line else cout<<num[j]<<","; // print the array} myFile.close(); //close the filereturn 0;}
Chapter 13 Solutions
EBK JAVA PROGRAMMING
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Which of the following is a correct opening of a file for writing to the file? Lütfen birini seçin: a. open(data.txt, "w") b. file = open("data.txt", "write") c. file = open(data.txt, "w") d. file = open("data.txt", "w") e. file = open("data.txt", "r")arrow_forwardIn Unix/Linux code: Write cmd lines for the following.1. Display lines that begin with upper case and end with lower case among the lines in a text file. Use any filename for your answer.2. Display shell programming scripts in /etc/init.d3. Is [] bracketed expression used in shell scripts under /etc/init.d ? Write a cmd line to evaluate this.Display all lines in all files in /etc/init.d which contains the pattern [] for test cmdarrow_forwardWhat would be the printout of the following code if the same file.txt was used as above? int main() { fstream file("file.txt", ios::in); string line; while (!file.eof()) { getline(file, line); cout << line << endl; } file.close(); return 0;} Group of answer choices I have a dream. I Ihaveadream. I have a dream.I have a dream.arrow_forward
- For example, if you create a file named: "users.txt" that contains these user names: daniel moshe yossy gabi ran bijo baruch bibi The following command run in an elevated command prompt will parse this file, and create a new user on your computer FOR /F %i in (users.txt) DO NET USER %i P@ssw0rd /ADD With two (2) other options that you specify for each user when they are added?arrow_forwardWrite a program that asks for the name of an input file. Then, read all the numbers in the file, and display the following information to the screen: count of numbers in the file sum of all numbers in the file average of all numbers in the file (to 2 decimal places) count of numbers in each range (100-199, 200-299, 300-399, etc.) The program should: display a hello message ask the user for an input file display the name of the input file validate the file opens correctly display statistical information as shown above display a goodbye messagearrow_forwardAssume the following files are in the working directory: $ ls output.txt notes1 notes2 notestxt notes3 notes4 output.1 output.2 output.3 output-1b output-2b Give commands for each of the following, using wildcards to express filenames with as few characters as possible. a. List all files that begin with output. b. List all files that end in txt. c. List the output. files only. d. List the output.1, output.3, notes1, and notes3 files.arrow_forward
- Why is it considered good practice to open a file from within a Python script using (a) instead of (b)? (a) with open(‘textfile.txt’,’r’) as f: f.readlines() (b) f=open(‘textfile.txt’,’r’) f.readlines() f.close() a. When you open a file using the with keyword in Python, Python will make sure the file gets closed, even if an exception or error is thrown. b. The with keyword lets you choose which application to open the file in. c. The with keyword acts like a for loop, and lets you access each line in the file one by one. d. There is no benefit to using the with keyword for opening a file in Python.arrow_forwardWhat will be the content of 'file.c' after executing the following program? #include<stdio.h> int main() { FILE *fp1, *fp2; fp1=fopen("file.c", "w"); fp2=fopen("file.c", "w"); fputc('A', fp1); fputc('B', fp2); fclose(fp1); fclose(fp2); return 0; }arrow_forwardDescribe the mode that each of the following statements causes a file to beopened in.fi l e .open("in fo .dat ", io s: :infile.open("info.dat", io s: :infile.open("info.dat", io s: :infile.open("info.dat", io s: :inios: :out);ios::app);ios: :out I ios: :a te );ios::out I ios::binary);arrow_forward
- Given a text file opened for reading identified by tfile, which of the following will assign the next five characters from the file to the variable five_ch five_ch = tfile.read_char(5) tfile = five_ch.read_char(5) tfile = five_ch.read_char(6) five_ch = tfile.read_char(6)arrow_forward. Which of the following options can be used to read the first line of a text file "Myfile.txt"? a. myfile = open('Myfile.txt'); print(myfile.read(line)) b. myfile = open('Myfile.txt','r'); print(myfile.read(1)) c. myfile = open('Myfile.txt'); print(myfile.readline()) d. myfile = open('Myfile.txt'); print(myfile.readlines())arrow_forwardWrites the contents of a file one page at a time, using the command write-page. O a. Less O b. More O a. Less O c. Head O d. Tail O c. Head O d. Tailarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
C - File I/O; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=cEfuwpbGi1k;License: Standard YouTube License, CC-BY
file handling functions in c | fprintf, fscanf, fread, fwrite |; Author: Education 4u;https://www.youtube.com/watch?v=aqeXS1bJihA;License: Standard Youtube License