73 lines
4.7 KiB
HTML
73 lines
4.7 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
|
<html>
|
|
<head>
|
|
<title>Large.java</title>
|
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
|
<style type="text/css">
|
|
<!--
|
|
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
|
|
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
|
|
table {color: #888888; background-color: #313335; font-family: monospace; font-weight: bold}
|
|
.literal {color: #cc7832}
|
|
.ST0 {color: #287bde}
|
|
.string {color: #6a8759}
|
|
.number {color: #6897bb}
|
|
.comment {color: #808080}
|
|
.whitespace {color: #505050}
|
|
.ST1 {color: #ffc66d; font-family: monospace; font-weight: bold; font-style: italic}
|
|
.ST2 {color: #9876aa; font-family: monospace; font-weight: bold; font-style: italic}
|
|
-->
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/Large.java</td></tr></table>
|
|
<pre>
|
|
<span class="comment">/*</span>
|
|
<span class="comment"> * Click </span><span class="ST0">nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt</span><span class="comment"> to change this license</span>
|
|
<span class="comment"> * Click </span><span class="ST0">nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java</span><span class="comment"> to edit this template</span>
|
|
<span class="comment"> */</span>
|
|
<span class="literal">package</span> com.calebfontenot.mp5_calebfontenot;
|
|
|
|
<span class="literal">import</span> java.io.File;
|
|
<span class="comment">import</span> <span class="comment">java</span><span class="comment">.</span><span class="comment">io</span><span class="comment">.</span><span class="comment">FileNotFoundException</span><span class="comment">;</span>
|
|
<span class="literal">import</span> java.util.ArrayList;
|
|
<span class="literal">import</span> java.util.Scanner;
|
|
|
|
<span class="comment">/**</span>
|
|
<span class="comment"> *</span>
|
|
<span class="comment"> * </span><span class="comment">@author</span> <span class="comment">caleb</span>
|
|
<span class="comment">*/</span>
|
|
<span class="literal">public</span> <span class="literal">class</span> Large {
|
|
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST1">main</span>(String[] args) {
|
|
<span class="comment">// Read data file</span>
|
|
<span class="comment">// ArrayLists</span>
|
|
ArrayList firstNameArr = <span class="literal">new</span> ArrayList();
|
|
ArrayList lastNameArr = <span class="literal">new</span> ArrayList();
|
|
ArrayList jobTitleArr = <span class="literal">new</span> ArrayList();
|
|
ArrayList salaryArr = <span class="literal">new</span> ArrayList();
|
|
|
|
File file = <span class="literal">new</span> File(<span class="string">"</span><span class="string">Salary.txt</span><span class="string">"</span>);
|
|
<span class="literal">try</span> (Scanner fileScanner = <span class="literal">new</span> Scanner(file)) {
|
|
<span class="literal">while</span> (fileScanner.hasNext()) {
|
|
firstNameArr.add(fileScanner.next());
|
|
lastNameArr.add(fileScanner.next());
|
|
jobTitleArr.add(fileScanner.next());
|
|
salaryArr.add(fileScanner.next());
|
|
fileScanner.nextLine(); <span class="comment">// consume newline</span>
|
|
}
|
|
} <span class="literal">catch</span> (Exception ex) {
|
|
System.<span class="ST2">out</span>.println(<span class="string">"</span><span class="string">Unable to read file</span><span class="string">"</span>);
|
|
}
|
|
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < firstNameArr.size(); ++i) {
|
|
System.<span class="ST2">out</span>.println(<span class="string">"</span><span class="string">first name :</span><span class="string">"</span> + firstNameArr.get(i));
|
|
System.<span class="ST2">out</span>.println(<span class="string">"</span><span class="string">last name: </span><span class="string">"</span> + lastNameArr.get(i));
|
|
System.<span class="ST2">out</span>.println(<span class="string">"</span><span class="string">job title: </span><span class="string">"</span> + jobTitleArr.get(i));
|
|
System.<span class="ST2">out</span>.println(<span class="string">"</span><span class="string">salary: </span><span class="string">"</span> + salaryArr.get(i));
|
|
System.<span class="ST2">out</span>.println(<span class="string">"</span><span class="string">--------------------------------------</span><span class="string">"</span>);
|
|
}
|
|
}
|
|
}
|
|
|
|
</pre></body>
|
|
</html>
|