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
katrin2010 [14]
3 years ago
11

Write code that will copy the contents of the file into an array. You can assume that the file will only have 5 data values

Computers and Technology
1 answer:
SpyIntel [72]3 years ago
8 0

Answer:

Explanation:

The following code is written in Java. It is a function that reads the file in the URL that is given in the parameter. It then places the file into a String and assumes that each element is separated by a space (" "). It then loops through that string adding each element into the created local ArrayList. Finally, It prints the contents of the ArrayList and returns the ArrayList.

public static ArrayList<String> toArray (String file) throws IOException {

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

               BufferedReader reader = new BufferedReader(new FileReader(file));

               String readFile = reader.readLine();

               reader.close();

               for (int x = 0; x < readFile.length(); x++) {

                       int start = 0;

                       if (readFile.charAt(x) == ' ') {

                               myArr.add(readFile.substring(start,x));

                               start = x + 1;

                       }

               }

               for (String x : myArr) {

                       System.out.println(x);

               }

               

               return myArr;

       }

You might be interested in
Flexibility and cost reduction are advantages generally associated with ? networks.
ahrayia [7]

Answer:

Wireless networks

Explanation:

Wireless networks provide more configuration flexibility and are less expensive. Companies that add employees will greatly benefit from the flexibility of wireless connections. Workstations can be moved with ease without the effort and cost required to run wires and cables. It is the best for network expansion since companies can add users quickly and grow their networks cost-effectively.

7 0
3 years ago
72. In Object Oriented Programming, a class_____ starts
tangare [24]

it's...

Explanation:

there 283629471847153-$&3-_&

3 0
3 years ago
Carina is concerned that her computer is slowing down because it doesn’t have enough short-term memory. Which of the following s
steposvetlana [31]
I would say I think RAM? Hope this helps;)
8 0
3 years ago
Read 2 more answers
ZyDE 1.4.2: Fixing syntax errors.
skad [1K]

Using the knowledge of computational language in JAVA it is possible to write a code that Fixing syntax errors Click run to compile, and note the long error list.

<h3>Writting the code:</h3>

<em>public class BeansInJars {</em>

<em>    public static void main(String[] args) {</em>

<em>        int numBeans;</em>

<em>        int numJars;</em>

<em>        int totalBeans;</em>

<em>        numBeans = 500;</em>

<em>        numJars = 3;</em>

<em>        System.out.print(numBeans + " beans in ");</em>

<em>        System.out.print(numJars + " jars yields ");</em>

<em>        totalBeans = numBeans * numJars;</em>

<em>        System.out.println(totalBeans + " total");</em>

<em>    }</em>

<em>}</em>

See more about JAVA at brainly.com/question/12975450

#SPJ1

5 0
2 years ago
What is the main purpose of a graphic organizer?
timama [110]
B. To organize information using shapes.
8 0
3 years ago
Read 2 more answers
Other questions:
  • "The correct syntax for passing an array as an argument to a method when a method is called and an array is passed to it is: "
    15·1 answer
  • You have two DCs, each with three Active Directory-integrated zones. You're getting inconsistent DNS lookup results and suspect
    8·1 answer
  • The part of a rocket engine that allows the combustion gases and flames to leave the rocket engine is the
    14·1 answer
  • Write a perl program that reads from a file containing a list of names and then displays that list to a user. The program should
    11·1 answer
  • Briefly explain what an array is. As part of your answer make use of a labelled example to show the declaration and components o
    5·1 answer
  • They are correct? thank you!
    5·1 answer
  • What is a Web server application?
    7·1 answer
  • Why people shouldnt get married​
    6·1 answer
  • I need some help with this project. The picture of the assignment is above
    9·1 answer
  • Select all the correct answers. Which two statements are true about electric current through a circuit? Current flows from a pos
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!