1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
swat32
3 years ago
6

Complete the code to create a new file.

Computers and Technology
1 answer:
Mila [183]3 years ago
3 0

The code segments are illustrations of file manipulations

  • The character that completes the code to create a new file is W
  • The character that completes the code to add to a new file is A.

<h3>Creating a new file</h3>

When a new file is created, the default file mode is the write mode.

This in other words means that, we are writing to a file.

So, the character that completes the code to create a new file is W

<h3>Adding to a new file</h3>

To add texts to a file, is to append texts to the file.

This means that, the file is an existing file that needs to be updated.

So, the character that completes the code to add to a new file is A.

Read more about file manipulations at:

brainly.com/question/25324400

You might be interested in
create a new Java application called "CheckString" (without the quotation marks) according to the following guidelines.** Each m
jok3333 [9.3K]

Answer:

The Java code is given below

Explanation:

import java.io.*;

import java.util.Scanner;

import java.util.ArrayList;

public class StringCheck{

//There are several implementation approaches. This is one example framework/outline which might be helpful. Please feel free to try other approaches.

public static void checkWord(String word) throws Exception {

// Uses charAt method to test if the first letter of string variable word

// is a character. If not, throw new exception

if(Character.isLetter(word.charAt(0))){

 return;

}else{

 throw new Exception("This is not a word");

}

}

public static String getWord() {

// Declare a local scanner

// Prompt the user to enter a word

// Think about using a loop to give the user multiple opportunities to correctly enter a string

// Read into a string

// Call checkWord method passing the string as a parameter

// checkWord can throw an exception; call checkWord in a try/catch block

// Return the string to main if a valid string

Scanner sc = new Scanner(System.in);

boolean st = true;

String word = null;

while(st){

 System.out.println("Enter a Word : ");

 word = sc.next();

 try{

  checkWord(word);

  st = false;

 }catch(Exception e){

  System.out.println(e);

  st = true;

 }

}

sc.close();

return word;

}

public static void writeFile(String[] arrayToWrite, String filename) throws IOException {

// Example using FileWriter but PrintWriter could be used instead

// Create a FileWriter object

FileWriter fileWordStream = new FileWriter(filename);

// Use a loop to write string elements in arrayToWrite to fileWordStream

for(int i = 0;i<arrayToWrite.length;i++){

fileWordStream.write(arrayToWrite[i]+System.lineSeparator());

}

fileWordStream.flush();

fileWordStream.close();

// In the loop use the lineSeparator method to put each string on its own line

}

public static ArrayList readFile(String filename) throws FileNotFoundException, IOException {

// Declare local ArrayList

ArrayList<String> words = new ArrayList<>();

// Create a new File object using filename parameter

File file = new File(filename);

// Check if the file exists, if not throw a new exception

if(!file.exists()){

 throw new FileNotFoundException("File not Found");

}

// Create a new BufferedReader object      

Scanner fsc = new Scanner(file);

// use a loop and the readLine method to read each string (on its own line) from the file

while(fsc.hasNextLine()){

words.add(fsc.nextLine());

}

fsc.close();

// return the filled ArrayList to main

return words;

}

public static void main(String[] args) {

// create a string with literal values to write to the file

String[] testData = {"cat", "dog", "rabbit"};

// Create an ArrayList for reading the file

ArrayList<String> words = new ArrayList<>();

// Declare a string variable containing the file name "data.txt"

String file = "data.txt";

// Call getWord, assign the returned string to a variable and display it

String word = getWord();

System.out.println("The word is : "+word);

// Call writeFile and readFile methods in a try block

try{

writeFile(testData,file);

words = readFile(file);

// Printout the contents of the ArrayList after the call to readFile

for(int i = 0;i<words.size();i++){

 System.out.println(words.get(i));

}

}catch(FileNotFoundException e){

System.out.println(e);

}catch(IOException e){

System.out.println("IOException: error occured in input output");

}

// catch two types of exceptions

}

}

4 0
4 years ago
A car has an odometer which at the start of a journey shows 99940 and at the end shows 00230.what is the result of subtracting 9
vampirchik [111]

Answer:

99,710

Explanation:

Thats what my calculator said

5 0
3 years ago
Does using interior lighting help improve a drivers visibility at night
marin [14]
No, interior lighting makes less visibility for drivers. It becomes harder to see out the window.
8 0
4 years ago
Relatively simple CRUD (create, read, update, delete) web applications development can be facilitated with: _________.
Talja [164]

Answer:

c. Web Application Frameworks

Explanation:

Web Application Frameworks is a form of a software framework that is made to perform support for the building of web applications such as web services, web resources, and web APIs. Web frameworks.

Also, Web Application Frameworks automatically perform the function of primary activities carried out in web development such as create, read, update, delete.

Hence, in this case, the correct answer is Web Application Framework.

5 0
3 years ago
Plz plz plz subsribe to my channel, CookieFunTime
Nesterboy [21]

ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok

7 0
3 years ago
Other questions:
  • Mutual authentication for multiple services is also known as _______.
    12·1 answer
  • Given a string, return a version without the first and last char, so "Hello" yields "ell". The string length will be at least 2.
    13·1 answer
  • Which invention provided instant communication and information to a massive audience for the first time?
    9·2 answers
  • Average of Grades - Write a program that stores the following values in five different variables: 98, 87, 84, 100, 94. The progr
    8·1 answer
  • Which is considered the best way to secure a laptop to a desk in a workplace?
    12·1 answer
  • Which part of the Word screen matches label A?
    13·1 answer
  • Disadvantages of Batch<br>operation system​
    5·1 answer
  • In Linux, users are internally represented using a unique number called user ID or uid.
    9·1 answer
  • Why do software managers have to be generalists with a range of skills, rather than simply technical specialists?
    14·1 answer
  • A director was fined heavily for shooting in his own house in New York. What do you think was his mistake?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!