SlideShare a Scribd company logo
1 of 10
Download to read offline
How do I add another txt.file to this? I'm trying to add this to below...can someone help me
please?
US;NONRESIDENT;123456;Jones;123 Cooper St;Arlington;Texas;76019;12345
INT;ACTIVE;A-654789;Degrassey;18 Love Lane;Dallas;Texas;75052;67123
INT;INACTIVE;A-543891;Franco;1201 Trail Road;Euless;Texas;74032;19814
US;RESIDENT;345123;Hughes;1803 Division;Fort Worth;Texas;76034;674532
US;RESIDENT;988776;Cooper;111 Marsh Lane;Bedford;Texas;76111;90906
INT;INACTIVE;B-577463;Patel;2218 Border St;Arlington;Texas;76015;81832
package writefiles;
import java.util.*;
import java.io.*;
import javax.swing.*;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
public class WriteFiles {
private static Formatter output;
private static Scanner input;
public static void main(String[] args) {
ArrayList coursesList = new ArrayList();
writeTextFile();
readTextFile(coursesList);
for (Course c: coursesList){
System.out.println(c.toString());
}
writeSerFile(coursesList);
readSerFile();
}
public static void writeTextFile(){
try
{
Formatter output = new Formatter("courses.txt");
output.format("%s;%s;%s;%d;%d%n","Python", "INSY 3300", "560-650 MW", 1, 3);
output.format("%s;%s;%s;%d;%d%n","Networking", "INSY 3303", "530-650 TR", 1, 3);
output.format("%s;%s;%s;%d;%d%n","DBMS", "INSY 3304", "900-950 MWF", 1, 3);
output.format("%s;%s;%s;%d;%d%n","Analysis&Design", "INSY 3305", "700-820 TR",
1, 3);
output.format("%s;%s;%s;%d;%d%n","Java I", "INSY 4305", "700-820 TR", 1, 3);
output.format("%s;%s;%s;%d;%d%n","Java II", "INSY 4306", "530-650 TR", 1, 3);
output.format("%s;%s;%s;%d;%d%n","Mobile App", "INSY 4308", "200-320 TR", 1, 3);
output.format("%s;%s;%s;%d;%d%n","Web Development", "INSY 4315", "1000-1050
MWF", 1, 3);
output.format("%s;%s;%s;%d;%d%n","Resource Management", "INSY 4325", "100-220
TR", 1, 3);
output.flush();
output.close();
}
catch(IOException ioe){
ioe.printStackTrace();
}
}
public static void readTextFile(ArrayList coursesList){
String line;
String values[];
try{
input = new Scanner(getFile());
while(input.hasNext())
{
line = input.nextLine();
values = line.split(";");
coursesList.add(new Course(values[0], values[1], values[2],
Integer.parseInt(values[3]), Integer
.parseInt(values[4])));
}
}
catch (IOException ioe){
ioe.printStackTrace();
}
}
public static void writeSerFile(ArrayListcoursesList){
ObjectOutputStream output;
try{
output = new ObjectOutputStream(new FileOutputStream("courses.ser"));
for (Course c: coursesList){
output.writeObject(c);
}
}
catch(IOException ioe){
ioe.printStackTrace();
}
}
public static void readSerFile(){
ObjectInputStream input;
Course obj;
try{
input = new ObjectInputStream(new FileInputStream(getFile()));
while(true){
obj = (Course)input.readObject();
System.out.println(obj.toString());
}
}
catch(EOFException eof){
}
catch(ClassNotFoundException cnfe){
cnfe.printStackTrace();
}
catch(IOException ioe){
ioe.printStackTrace();
}
}
public static File getFile()
{
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
int result = fileChooser.showOpenDialog(null);
if (result == JFileChooser.CANCEL_OPTION){
System.exit(1);
}
File fileName = fileChooser.getSelectedFile();
if ((fileName == null) || (fileName.getName().equals(""))){
JOptionPane.showMessageDialog(null, "Invalid Option",
"Invalid Option", JOptionPane.ERROR_MESSAGE);
System.exit(1);
}
return fileName;
}
}
Solution
We need to create new course constructor and new function to read file. And remaining function
remins same.
//course constructor should be
public course(String val1, String val2, String val3,String val4, String val5,String val6,String
val7,int val8, int val9){
// initialise these variables in course file
}
-------------------------------------------------------------------------------------------------
// now I am modifying in our exact file
import java.util.*;
import java.io.*;
import javax.swing.*;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
public class WriteFiles {
private static Formatter output;
private static Scanner input;
public static void main(String[] args) {
ArrayList coursesList = new ArrayList();
writeTextFile();
readTextFile(coursesList);
readTextFileNew(coursesList); // calling seperate new method to read new format file
for (Course c: coursesList){
System.out.println(c.toString());
}
writeSerFile(coursesList);
readSerFile();
}
public static void writeTextFile(){
try
{
Formatter output = new Formatter("courses.txt");
output.format("%s;%s;%s;%d;%d%n","Python", "INSY 3300", "560-650 MW", 1, 3);
output.format("%s;%s;%s;%d;%d%n","Networking", "INSY 3303", "530-650 TR", 1, 3);
output.format("%s;%s;%s;%d;%d%n","DBMS", "INSY 3304", "900-950 MWF", 1, 3);
output.format("%s;%s;%s;%d;%d%n","Analysis&Design", "INSY 3305", "700-820 TR",
1, 3);
output.format("%s;%s;%s;%d;%d%n","Java I", "INSY 4305", "700-820 TR", 1, 3);
output.format("%s;%s;%s;%d;%d%n","Java II", "INSY 4306", "530-650 TR", 1, 3);
output.format("%s;%s;%s;%d;%d%n","Mobile App", "INSY 4308", "200-320 TR", 1, 3);
output.format("%s;%s;%s;%d;%d%n","Web Development", "INSY 4315", "1000-1050
MWF", 1, 3);
output.format("%s;%s;%s;%d;%d%n","Resource Management", "INSY 4325", "100-220
TR", 1, 3);
output.flush();
output.close();
}
catch(IOException ioe){
ioe.printStackTrace();
}
}
public static void readTextFile(ArrayList coursesList){
String line;
String values[];
try{
input = new Scanner(getFile());
while(input.hasNext())
{
line = input.nextLine();
values = line.split(";");
coursesList.add(new Course(values[0], values[1], values[2],
Integer.parseInt(values[3]), Integer
.parseInt(values[4])));
}
}
catch (IOException ioe){
ioe.printStackTrace();
}
}
public static void readTextFileNew(ArrayList coursesList){
String line;
String values[];
try{
input = new Scanner(getFile());
while(input.hasNext())
{
line = input.nextLine();
values = line.split(";");
coursesList.add(new Course(values[0], values[1],
values[2],values[3],values[4],values[5],values[6]
Integer.parseInt(values[7]), Integer.parseInt(values[8])));
}
}
catch (IOException ioe){
ioe.printStackTrace();
}
}
public static void writeSerFile(ArrayListcoursesList){
ObjectOutputStream output;
try{
output = new ObjectOutputStream(new FileOutputStream("courses.ser"));
for (Course c: coursesList){
output.writeObject(c);
}
}
catch(IOException ioe){
ioe.printStackTrace();
}
}
public static void readSerFile(){
ObjectInputStream input;
Course obj;
try{
input = new ObjectInputStream(new FileInputStream(getFile()));
while(true){
obj = (Course)input.readObject();
System.out.println(obj.toString());
}
}
catch(EOFException eof){
}
catch(ClassNotFoundException cnfe){
cnfe.printStackTrace();
}
catch(IOException ioe){
ioe.printStackTrace();
}
}
public static File getFile()
{
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
int result = fileChooser.showOpenDialog(null);
if (result == JFileChooser.CANCEL_OPTION){
System.exit(1);
}
File fileName = fileChooser.getSelectedFile();
if ((fileName == null) || (fileName.getName().equals(""))){
JOptionPane.showMessageDialog(null, "Invalid Option",
"Invalid Option", JOptionPane.ERROR_MESSAGE);
System.exit(1);
}
return fileName;
}
}

More Related Content

Similar to How do I add another txt.file to this Im trying to add this to be.pdf

New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docxNew folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docxcurwenmichaela
 
Assignmentwilliamstearman_java301.zipWilliamStearman_Java30.docx
Assignmentwilliamstearman_java301.zipWilliamStearman_Java30.docxAssignmentwilliamstearman_java301.zipWilliamStearman_Java30.docx
Assignmentwilliamstearman_java301.zipWilliamStearman_Java30.docxssuser562afc1
 
please navigate to cs112 webpage and go to assignments -- Trees. Th.pdf
please navigate to cs112 webpage and go to assignments -- Trees. Th.pdfplease navigate to cs112 webpage and go to assignments -- Trees. Th.pdf
please navigate to cs112 webpage and go to assignments -- Trees. Th.pdfaioils
 
StackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdfStackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdfARCHANASTOREKOTA
 
Data structuresUsing java language and develop a prot.pdf
Data structuresUsing java language and develop a prot.pdfData structuresUsing java language and develop a prot.pdf
Data structuresUsing java language and develop a prot.pdfarmyshoes
 
Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015Lukas Ruebbelke
 
Teste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrityTeste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrityWashington Botelho
 
Python mu Java mı?
Python mu Java mı?Python mu Java mı?
Python mu Java mı?aerkanc
 
package algs13;import stdlib.;import java.util.Iterator;im.docx
package algs13;import  stdlib.;import java.util.Iterator;im.docxpackage algs13;import  stdlib.;import java.util.Iterator;im.docx
package algs13;import stdlib.;import java.util.Iterator;im.docxgerardkortney
 
vfsStream - effective filesystem mocking
vfsStream - effective filesystem mocking vfsStream - effective filesystem mocking
vfsStream - effective filesystem mocking Sebastian Marek
 
So I have this code(StackInAllSocks) and I implemented the method but.pdf
So I have this code(StackInAllSocks) and I implemented the method but.pdfSo I have this code(StackInAllSocks) and I implemented the method but.pdf
So I have this code(StackInAllSocks) and I implemented the method but.pdfaksahnan
 
DI Frameworks - hidden pearls
DI Frameworks - hidden pearlsDI Frameworks - hidden pearls
DI Frameworks - hidden pearlsSven Ruppert
 
(In java language)1. Use recursion in implementing the binarySearc.pdf
(In java language)1. Use recursion in implementing the binarySearc.pdf(In java language)1. Use recursion in implementing the binarySearc.pdf
(In java language)1. Use recursion in implementing the binarySearc.pdfrbjain2007
 
Modify this code to change the underlying data structure to .pdf
Modify this code to change the underlying data structure to .pdfModify this code to change the underlying data structure to .pdf
Modify this code to change the underlying data structure to .pdfadityaenterprise32
 

Similar to How do I add another txt.file to this Im trying to add this to be.pdf (20)

New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docxNew folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
 
Reason and GraphQL
Reason and GraphQLReason and GraphQL
Reason and GraphQL
 
Assignmentwilliamstearman_java301.zipWilliamStearman_Java30.docx
Assignmentwilliamstearman_java301.zipWilliamStearman_Java30.docxAssignmentwilliamstearman_java301.zipWilliamStearman_Java30.docx
Assignmentwilliamstearman_java301.zipWilliamStearman_Java30.docx
 
please navigate to cs112 webpage and go to assignments -- Trees. Th.pdf
please navigate to cs112 webpage and go to assignments -- Trees. Th.pdfplease navigate to cs112 webpage and go to assignments -- Trees. Th.pdf
please navigate to cs112 webpage and go to assignments -- Trees. Th.pdf
 
StackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdfStackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdf
 
Data structuresUsing java language and develop a prot.pdf
Data structuresUsing java language and develop a prot.pdfData structuresUsing java language and develop a prot.pdf
Data structuresUsing java language and develop a prot.pdf
 
Java 7
Java 7Java 7
Java 7
 
Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015
 
Teste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrityTeste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrity
 
Python mu Java mı?
Python mu Java mı?Python mu Java mı?
Python mu Java mı?
 
Java 5 and 6 New Features
Java 5 and 6 New FeaturesJava 5 and 6 New Features
Java 5 and 6 New Features
 
package algs13;import stdlib.;import java.util.Iterator;im.docx
package algs13;import  stdlib.;import java.util.Iterator;im.docxpackage algs13;import  stdlib.;import java.util.Iterator;im.docx
package algs13;import stdlib.;import java.util.Iterator;im.docx
 
vfsStream - effective filesystem mocking
vfsStream - effective filesystem mocking vfsStream - effective filesystem mocking
vfsStream - effective filesystem mocking
 
So I have this code(StackInAllSocks) and I implemented the method but.pdf
So I have this code(StackInAllSocks) and I implemented the method but.pdfSo I have this code(StackInAllSocks) and I implemented the method but.pdf
So I have this code(StackInAllSocks) and I implemented the method but.pdf
 
DI Frameworks - hidden pearls
DI Frameworks - hidden pearlsDI Frameworks - hidden pearls
DI Frameworks - hidden pearls
 
(In java language)1. Use recursion in implementing the binarySearc.pdf
(In java language)1. Use recursion in implementing the binarySearc.pdf(In java language)1. Use recursion in implementing the binarySearc.pdf
(In java language)1. Use recursion in implementing the binarySearc.pdf
 
XTW_Import
XTW_ImportXTW_Import
XTW_Import
 
Modify this code to change the underlying data structure to .pdf
Modify this code to change the underlying data structure to .pdfModify this code to change the underlying data structure to .pdf
Modify this code to change the underlying data structure to .pdf
 
Code red SUM
Code red SUMCode red SUM
Code red SUM
 
Bhaloo
BhalooBhaloo
Bhaloo
 

More from fatoryoutlets

Write an informal paper that is exactly 3 pages long not counting th.pdf
Write an informal paper that is exactly 3 pages long not counting th.pdfWrite an informal paper that is exactly 3 pages long not counting th.pdf
Write an informal paper that is exactly 3 pages long not counting th.pdffatoryoutlets
 
Write a C program to find factorial of an integer n, where the user .pdf
Write a C program to find factorial of an integer n, where the user .pdfWrite a C program to find factorial of an integer n, where the user .pdf
Write a C program to find factorial of an integer n, where the user .pdffatoryoutlets
 
When was the black body mutation in drosophila melanogaster discover.pdf
When was the black body mutation in drosophila melanogaster discover.pdfWhen was the black body mutation in drosophila melanogaster discover.pdf
When was the black body mutation in drosophila melanogaster discover.pdffatoryoutlets
 
What is it that consumer researchers try to find among varying cultu.pdf
What is it that consumer researchers try to find among varying cultu.pdfWhat is it that consumer researchers try to find among varying cultu.pdf
What is it that consumer researchers try to find among varying cultu.pdffatoryoutlets
 
What are pros and cons of Symantec endpoint security softwareSo.pdf
What are pros and cons of Symantec endpoint security softwareSo.pdfWhat are pros and cons of Symantec endpoint security softwareSo.pdf
What are pros and cons of Symantec endpoint security softwareSo.pdffatoryoutlets
 
All of the following describe the International Accounting Standard .pdf
All of the following describe the International Accounting Standard .pdfAll of the following describe the International Accounting Standard .pdf
All of the following describe the International Accounting Standard .pdffatoryoutlets
 
The right and left sternocleidomastoid muscles of humans originate o.pdf
The right and left sternocleidomastoid muscles of humans originate o.pdfThe right and left sternocleidomastoid muscles of humans originate o.pdf
The right and left sternocleidomastoid muscles of humans originate o.pdffatoryoutlets
 
The code in image3.cpp has the error as shown above, could you help .pdf
The code in image3.cpp has the error as shown above, could you help .pdfThe code in image3.cpp has the error as shown above, could you help .pdf
The code in image3.cpp has the error as shown above, could you help .pdffatoryoutlets
 
the ability of the cardiac muscle cells to fire on their own is .pdf
the ability of the cardiac muscle cells to fire on their own is .pdfthe ability of the cardiac muscle cells to fire on their own is .pdf
the ability of the cardiac muscle cells to fire on their own is .pdffatoryoutlets
 
Template LinkedList;I am using templates to make some linkedLists.pdf
Template LinkedList;I am using templates to make some linkedLists.pdfTemplate LinkedList;I am using templates to make some linkedLists.pdf
Template LinkedList;I am using templates to make some linkedLists.pdffatoryoutlets
 
Surface water entering the North Atlantic may have a temperature of .pdf
Surface water entering the North Atlantic may have a temperature of .pdfSurface water entering the North Atlantic may have a temperature of .pdf
Surface water entering the North Atlantic may have a temperature of .pdffatoryoutlets
 
Suppose the rate of plant growth on Isle Royale supported an equilib.pdf
Suppose the rate of plant growth on Isle Royale supported an equilib.pdfSuppose the rate of plant growth on Isle Royale supported an equilib.pdf
Suppose the rate of plant growth on Isle Royale supported an equilib.pdffatoryoutlets
 
Q1. public void operationZ() throws StackUnderflowException {   .pdf
Q1. public void operationZ() throws StackUnderflowException {   .pdfQ1. public void operationZ() throws StackUnderflowException {   .pdf
Q1. public void operationZ() throws StackUnderflowException {   .pdffatoryoutlets
 
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdf
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdfPrint Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdf
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdffatoryoutlets
 
Part A 1. Solid product forms during the addition of the bleach solu.pdf
Part A 1. Solid product forms during the addition of the bleach solu.pdfPart A 1. Solid product forms during the addition of the bleach solu.pdf
Part A 1. Solid product forms during the addition of the bleach solu.pdffatoryoutlets
 
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdf
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdfOnly 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdf
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdffatoryoutlets
 
Note Use Java Write a web server that is capable of processing only.pdf
Note Use Java Write a web server that is capable of processing only.pdfNote Use Java Write a web server that is capable of processing only.pdf
Note Use Java Write a web server that is capable of processing only.pdffatoryoutlets
 
Negotiations are not usually faster in Deal focused cultures than re.pdf
Negotiations are not usually faster in Deal focused cultures than re.pdfNegotiations are not usually faster in Deal focused cultures than re.pdf
Negotiations are not usually faster in Deal focused cultures than re.pdffatoryoutlets
 
9. The tort of assault and the tort of battery A) can occur independe.pdf
9. The tort of assault and the tort of battery A) can occur independe.pdf9. The tort of assault and the tort of battery A) can occur independe.pdf
9. The tort of assault and the tort of battery A) can occur independe.pdffatoryoutlets
 
Jj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdf
Jj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdfJj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdf
Jj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdffatoryoutlets
 

More from fatoryoutlets (20)

Write an informal paper that is exactly 3 pages long not counting th.pdf
Write an informal paper that is exactly 3 pages long not counting th.pdfWrite an informal paper that is exactly 3 pages long not counting th.pdf
Write an informal paper that is exactly 3 pages long not counting th.pdf
 
Write a C program to find factorial of an integer n, where the user .pdf
Write a C program to find factorial of an integer n, where the user .pdfWrite a C program to find factorial of an integer n, where the user .pdf
Write a C program to find factorial of an integer n, where the user .pdf
 
When was the black body mutation in drosophila melanogaster discover.pdf
When was the black body mutation in drosophila melanogaster discover.pdfWhen was the black body mutation in drosophila melanogaster discover.pdf
When was the black body mutation in drosophila melanogaster discover.pdf
 
What is it that consumer researchers try to find among varying cultu.pdf
What is it that consumer researchers try to find among varying cultu.pdfWhat is it that consumer researchers try to find among varying cultu.pdf
What is it that consumer researchers try to find among varying cultu.pdf
 
What are pros and cons of Symantec endpoint security softwareSo.pdf
What are pros and cons of Symantec endpoint security softwareSo.pdfWhat are pros and cons of Symantec endpoint security softwareSo.pdf
What are pros and cons of Symantec endpoint security softwareSo.pdf
 
All of the following describe the International Accounting Standard .pdf
All of the following describe the International Accounting Standard .pdfAll of the following describe the International Accounting Standard .pdf
All of the following describe the International Accounting Standard .pdf
 
The right and left sternocleidomastoid muscles of humans originate o.pdf
The right and left sternocleidomastoid muscles of humans originate o.pdfThe right and left sternocleidomastoid muscles of humans originate o.pdf
The right and left sternocleidomastoid muscles of humans originate o.pdf
 
The code in image3.cpp has the error as shown above, could you help .pdf
The code in image3.cpp has the error as shown above, could you help .pdfThe code in image3.cpp has the error as shown above, could you help .pdf
The code in image3.cpp has the error as shown above, could you help .pdf
 
the ability of the cardiac muscle cells to fire on their own is .pdf
the ability of the cardiac muscle cells to fire on their own is .pdfthe ability of the cardiac muscle cells to fire on their own is .pdf
the ability of the cardiac muscle cells to fire on their own is .pdf
 
Template LinkedList;I am using templates to make some linkedLists.pdf
Template LinkedList;I am using templates to make some linkedLists.pdfTemplate LinkedList;I am using templates to make some linkedLists.pdf
Template LinkedList;I am using templates to make some linkedLists.pdf
 
Surface water entering the North Atlantic may have a temperature of .pdf
Surface water entering the North Atlantic may have a temperature of .pdfSurface water entering the North Atlantic may have a temperature of .pdf
Surface water entering the North Atlantic may have a temperature of .pdf
 
Suppose the rate of plant growth on Isle Royale supported an equilib.pdf
Suppose the rate of plant growth on Isle Royale supported an equilib.pdfSuppose the rate of plant growth on Isle Royale supported an equilib.pdf
Suppose the rate of plant growth on Isle Royale supported an equilib.pdf
 
Q1. public void operationZ() throws StackUnderflowException {   .pdf
Q1. public void operationZ() throws StackUnderflowException {   .pdfQ1. public void operationZ() throws StackUnderflowException {   .pdf
Q1. public void operationZ() throws StackUnderflowException {   .pdf
 
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdf
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdfPrint Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdf
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdf
 
Part A 1. Solid product forms during the addition of the bleach solu.pdf
Part A 1. Solid product forms during the addition of the bleach solu.pdfPart A 1. Solid product forms during the addition of the bleach solu.pdf
Part A 1. Solid product forms during the addition of the bleach solu.pdf
 
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdf
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdfOnly 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdf
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdf
 
Note Use Java Write a web server that is capable of processing only.pdf
Note Use Java Write a web server that is capable of processing only.pdfNote Use Java Write a web server that is capable of processing only.pdf
Note Use Java Write a web server that is capable of processing only.pdf
 
Negotiations are not usually faster in Deal focused cultures than re.pdf
Negotiations are not usually faster in Deal focused cultures than re.pdfNegotiations are not usually faster in Deal focused cultures than re.pdf
Negotiations are not usually faster in Deal focused cultures than re.pdf
 
9. The tort of assault and the tort of battery A) can occur independe.pdf
9. The tort of assault and the tort of battery A) can occur independe.pdf9. The tort of assault and the tort of battery A) can occur independe.pdf
9. The tort of assault and the tort of battery A) can occur independe.pdf
 
Jj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdf
Jj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdfJj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdf
Jj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdf
 

Recently uploaded

Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdfssuserdda66b
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 

Recently uploaded (20)

Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 

How do I add another txt.file to this Im trying to add this to be.pdf

  • 1. How do I add another txt.file to this? I'm trying to add this to below...can someone help me please? US;NONRESIDENT;123456;Jones;123 Cooper St;Arlington;Texas;76019;12345 INT;ACTIVE;A-654789;Degrassey;18 Love Lane;Dallas;Texas;75052;67123 INT;INACTIVE;A-543891;Franco;1201 Trail Road;Euless;Texas;74032;19814 US;RESIDENT;345123;Hughes;1803 Division;Fort Worth;Texas;76034;674532 US;RESIDENT;988776;Cooper;111 Marsh Lane;Bedford;Texas;76111;90906 INT;INACTIVE;B-577463;Patel;2218 Border St;Arlington;Texas;76015;81832 package writefiles; import java.util.*; import java.io.*; import javax.swing.*; import javax.swing.JFileChooser; import javax.swing.JOptionPane; public class WriteFiles { private static Formatter output; private static Scanner input; public static void main(String[] args) { ArrayList coursesList = new ArrayList(); writeTextFile(); readTextFile(coursesList); for (Course c: coursesList){ System.out.println(c.toString()); } writeSerFile(coursesList); readSerFile(); }
  • 2. public static void writeTextFile(){ try { Formatter output = new Formatter("courses.txt"); output.format("%s;%s;%s;%d;%d%n","Python", "INSY 3300", "560-650 MW", 1, 3); output.format("%s;%s;%s;%d;%d%n","Networking", "INSY 3303", "530-650 TR", 1, 3); output.format("%s;%s;%s;%d;%d%n","DBMS", "INSY 3304", "900-950 MWF", 1, 3); output.format("%s;%s;%s;%d;%d%n","Analysis&Design", "INSY 3305", "700-820 TR", 1, 3); output.format("%s;%s;%s;%d;%d%n","Java I", "INSY 4305", "700-820 TR", 1, 3); output.format("%s;%s;%s;%d;%d%n","Java II", "INSY 4306", "530-650 TR", 1, 3); output.format("%s;%s;%s;%d;%d%n","Mobile App", "INSY 4308", "200-320 TR", 1, 3); output.format("%s;%s;%s;%d;%d%n","Web Development", "INSY 4315", "1000-1050 MWF", 1, 3); output.format("%s;%s;%s;%d;%d%n","Resource Management", "INSY 4325", "100-220 TR", 1, 3); output.flush(); output.close(); } catch(IOException ioe){ ioe.printStackTrace(); } } public static void readTextFile(ArrayList coursesList){ String line; String values[]; try{ input = new Scanner(getFile()); while(input.hasNext())
  • 3. { line = input.nextLine(); values = line.split(";"); coursesList.add(new Course(values[0], values[1], values[2], Integer.parseInt(values[3]), Integer .parseInt(values[4]))); } } catch (IOException ioe){ ioe.printStackTrace(); } } public static void writeSerFile(ArrayListcoursesList){ ObjectOutputStream output; try{ output = new ObjectOutputStream(new FileOutputStream("courses.ser")); for (Course c: coursesList){ output.writeObject(c); } } catch(IOException ioe){ ioe.printStackTrace(); } } public static void readSerFile(){ ObjectInputStream input; Course obj;
  • 4. try{ input = new ObjectInputStream(new FileInputStream(getFile())); while(true){ obj = (Course)input.readObject(); System.out.println(obj.toString()); } } catch(EOFException eof){ } catch(ClassNotFoundException cnfe){ cnfe.printStackTrace(); } catch(IOException ioe){ ioe.printStackTrace(); } } public static File getFile() { JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); int result = fileChooser.showOpenDialog(null); if (result == JFileChooser.CANCEL_OPTION){ System.exit(1); } File fileName = fileChooser.getSelectedFile(); if ((fileName == null) || (fileName.getName().equals(""))){ JOptionPane.showMessageDialog(null, "Invalid Option",
  • 5. "Invalid Option", JOptionPane.ERROR_MESSAGE); System.exit(1); } return fileName; } } Solution We need to create new course constructor and new function to read file. And remaining function remins same. //course constructor should be public course(String val1, String val2, String val3,String val4, String val5,String val6,String val7,int val8, int val9){ // initialise these variables in course file } ------------------------------------------------------------------------------------------------- // now I am modifying in our exact file import java.util.*; import java.io.*; import javax.swing.*; import javax.swing.JFileChooser; import javax.swing.JOptionPane; public class WriteFiles { private static Formatter output; private static Scanner input; public static void main(String[] args) { ArrayList coursesList = new ArrayList(); writeTextFile(); readTextFile(coursesList); readTextFileNew(coursesList); // calling seperate new method to read new format file
  • 6. for (Course c: coursesList){ System.out.println(c.toString()); } writeSerFile(coursesList); readSerFile(); } public static void writeTextFile(){ try { Formatter output = new Formatter("courses.txt"); output.format("%s;%s;%s;%d;%d%n","Python", "INSY 3300", "560-650 MW", 1, 3); output.format("%s;%s;%s;%d;%d%n","Networking", "INSY 3303", "530-650 TR", 1, 3); output.format("%s;%s;%s;%d;%d%n","DBMS", "INSY 3304", "900-950 MWF", 1, 3); output.format("%s;%s;%s;%d;%d%n","Analysis&Design", "INSY 3305", "700-820 TR", 1, 3); output.format("%s;%s;%s;%d;%d%n","Java I", "INSY 4305", "700-820 TR", 1, 3); output.format("%s;%s;%s;%d;%d%n","Java II", "INSY 4306", "530-650 TR", 1, 3); output.format("%s;%s;%s;%d;%d%n","Mobile App", "INSY 4308", "200-320 TR", 1, 3); output.format("%s;%s;%s;%d;%d%n","Web Development", "INSY 4315", "1000-1050 MWF", 1, 3); output.format("%s;%s;%s;%d;%d%n","Resource Management", "INSY 4325", "100-220 TR", 1, 3); output.flush(); output.close(); } catch(IOException ioe){ ioe.printStackTrace(); } }
  • 7. public static void readTextFile(ArrayList coursesList){ String line; String values[]; try{ input = new Scanner(getFile()); while(input.hasNext()) { line = input.nextLine(); values = line.split(";"); coursesList.add(new Course(values[0], values[1], values[2], Integer.parseInt(values[3]), Integer .parseInt(values[4]))); } } catch (IOException ioe){ ioe.printStackTrace(); } } public static void readTextFileNew(ArrayList coursesList){ String line; String values[]; try{ input = new Scanner(getFile()); while(input.hasNext()) {
  • 8. line = input.nextLine(); values = line.split(";"); coursesList.add(new Course(values[0], values[1], values[2],values[3],values[4],values[5],values[6] Integer.parseInt(values[7]), Integer.parseInt(values[8]))); } } catch (IOException ioe){ ioe.printStackTrace(); } } public static void writeSerFile(ArrayListcoursesList){ ObjectOutputStream output; try{ output = new ObjectOutputStream(new FileOutputStream("courses.ser")); for (Course c: coursesList){ output.writeObject(c); } } catch(IOException ioe){ ioe.printStackTrace(); } } public static void readSerFile(){ ObjectInputStream input; Course obj;
  • 9. try{ input = new ObjectInputStream(new FileInputStream(getFile())); while(true){ obj = (Course)input.readObject(); System.out.println(obj.toString()); } } catch(EOFException eof){ } catch(ClassNotFoundException cnfe){ cnfe.printStackTrace(); } catch(IOException ioe){ ioe.printStackTrace(); } } public static File getFile() { JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); int result = fileChooser.showOpenDialog(null); if (result == JFileChooser.CANCEL_OPTION){ System.exit(1); } File fileName = fileChooser.getSelectedFile(); if ((fileName == null) || (fileName.getName().equals(""))){ JOptionPane.showMessageDialog(null, "Invalid Option", "Invalid Option", JOptionPane.ERROR_MESSAGE);