SlideShare a Scribd company logo
1 of 5
Download to read offline
Here is my code for a line/file editor: Please help me figure out when I input "E" to exit and save
to the textin.txt file, it is not saving anything in textin.txt file. It also is prints "1>" twice when I
hit enter before it will move on to "2>" See my output below and the needed output and I need
the command "E" to save the output to the textin.txt file and terminate the program. "E"
terminates my program, but is not saving to the txt file.
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class FileEdit {
public static List lines = new ArrayList();
public static void main(String[] args) throws IOException
{
Scanner s = new Scanner(System.in);
System.out.print("EDIT: ");
String fileName = s.nextLine();
BufferedReader br = new BufferedReader(new FileReader(new File(fileName)));
String str="";
int count=0;
while((str=br.readLine())!=null)
{
lines.add(count, str);
System.out.println((++count) + "> "+ str);
}
String text="";
String command = "";
System.out.print((++count)+"> ");
command=s.nextLine();
String commandArr[];
int flag;
while(!command.equals("E"))
{
flag=0;
commandArr = command.split("s");
if(commandArr[0].equals("I")) //Insertion
{
while(true)
{
if(commandArr.length==1&&flag!=2)
{
System.out.print((count)+"> ");
text = s.nextLine();
insertLine(text,count-1);
}
else if(commandArr.length==2&&flag!=2)
{
System.out.print((commandArr[1])+"> ");
count=Integer.parseInt(commandArr[1]);
text = s.nextLine();
insertLine(text,Integer.parseInt(commandArr[1])-1);
}
else
insertLine(text,count-1);
System.out.print((++count)+"> ");
command=s.nextLine();
commandArr = command.split("s");
if(commandArr[0].equals("I")||commandArr[0].equals("L")||commandArr[0].equals("D")||comm
andArr[0].equals("E"))
{
flag=1;
break;
}
else
{
flag=2;
text=command;
}
}
}
else if(commandArr[0].equals("L")) //Listing
{
printList();
}
else if(commandArr[0].equals("D")) //Deletion
{
if(commandArr.length==1)
{
deleteLine(count-1,count-1);
}
else if(commandArr.length==2)
{
deleteLine(Integer.parseInt(commandArr[1])-1,Integer.parseInt(commandArr[1])-1);
}
else if(commandArr.length==3)
{
deleteLine(Integer.parseInt(commandArr[1])-1,Integer.parseInt(commandArr[2])-1);
}
count=lines.size();
}
if(flag!=1)
{
System.out.print((count++)+"> ");
command = s.nextLine();
}
}
}
public static void insertLine(String text,int count)
{
if (count >= lines.size()) {
for(int i = lines.size(); i <= count; i++) {
lines.add(null);
}
}
lines.set(count,text);
}
public static void deleteLine(int start,int end)
{
for(int i=start;i<=end;i++)
lines.remove(i);
}
public static void printList()
{
for(int i=0;i "+lines.get(i));
}
}
Here is the output I am getting:
EDIT: textin.txt
1> The First Line
1>
2> And another line
3> I 3
3> The second line
4> One more line
5> L
1>
2>
3> The second line
4> One more line
5> D 2
3> L
1>
2> The second line
3> One more line
4> E
Output needed and "E" to save to txt file and terminate program:
1> The first line
2>
3> And another line
4> I 3
3> The second line
4> One more line
5> L
1> The first line
2>
3> The second line
4> One more line
5> And another line
5> D 2
4> L
1> The first line
2> The second line
3> One more line
4> And another line
5> E

More Related Content

Similar to Here is my code for a linefile editor Please help me figure out wh.pdf

PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
Yashpatel821746
ย 
UserInputHandlerjava package midterm2023 import javautil.pdf
UserInputHandlerjava package midterm2023 import javautil.pdfUserInputHandlerjava package midterm2023 import javautil.pdf
UserInputHandlerjava package midterm2023 import javautil.pdf
adityknits
ย 
Description 1) Create a Lab2 folder for this project2.docx
Description       1)  Create a Lab2 folder for this project2.docxDescription       1)  Create a Lab2 folder for this project2.docx
Description 1) Create a Lab2 folder for this project2.docx
theodorelove43763
ย 
Python Exception handling using Try-Except-Finally
Python Exception handling using Try-Except-FinallyPython Exception handling using Try-Except-Finally
Python Exception handling using Try-Except-Finally
Vinod Srivastava
ย 
So I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdfSo I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdf
ezonesolutions
ย 
Network lap pgms 7th semester
Network lap pgms 7th semesterNetwork lap pgms 7th semester
Network lap pgms 7th semester
DOSONKA Group
ย 
java programming languageThe attached A12.txt file which has 2 col.pdf
java programming languageThe attached A12.txt file which has 2 col.pdfjava programming languageThe attached A12.txt file which has 2 col.pdf
java programming languageThe attached A12.txt file which has 2 col.pdf
nitinarora01
ย 
please help finish sorting methods- import java-util-Arrays- import ja.pdf
please help finish sorting methods- import java-util-Arrays- import ja.pdfplease help finish sorting methods- import java-util-Arrays- import ja.pdf
please help finish sorting methods- import java-util-Arrays- import ja.pdf
anfenterprises
ย 
TechTalk - Dotnet
TechTalk - DotnetTechTalk - Dotnet
TechTalk - Dotnet
heinrich.wendel
ย 
import java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdf
import java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdfimport java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdf
import java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdf
adhityalapcare
ย 

Similar to Here is my code for a linefile editor Please help me figure out wh.pdf (20)

Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...
Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...
Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...
ย 
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
ย 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
ย 
UserInputHandlerjava package midterm2023 import javautil.pdf
UserInputHandlerjava package midterm2023 import javautil.pdfUserInputHandlerjava package midterm2023 import javautil.pdf
UserInputHandlerjava package midterm2023 import javautil.pdf
ย 
Arrays and function basic c programming notes
Arrays and function basic c programming notesArrays and function basic c programming notes
Arrays and function basic c programming notes
ย 
Unit2 input output
Unit2 input outputUnit2 input output
Unit2 input output
ย 
Description 1) Create a Lab2 folder for this project2.docx
Description       1)  Create a Lab2 folder for this project2.docxDescription       1)  Create a Lab2 folder for this project2.docx
Description 1) Create a Lab2 folder for this project2.docx
ย 
Python Programming: Lists, Modules, Exceptions
Python Programming: Lists, Modules, ExceptionsPython Programming: Lists, Modules, Exceptions
Python Programming: Lists, Modules, Exceptions
ย 
Python Exception handling using Try-Except-Finally
Python Exception handling using Try-Except-FinallyPython Exception handling using Try-Except-Finally
Python Exception handling using Try-Except-Finally
ย 
So I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdfSo I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdf
ย 
Network lap pgms 7th semester
Network lap pgms 7th semesterNetwork lap pgms 7th semester
Network lap pgms 7th semester
ย 
java programming languageThe attached A12.txt file which has 2 col.pdf
java programming languageThe attached A12.txt file which has 2 col.pdfjava programming languageThe attached A12.txt file which has 2 col.pdf
java programming languageThe attached A12.txt file which has 2 col.pdf
ย 
please help finish sorting methods- import java-util-Arrays- import ja.pdf
please help finish sorting methods- import java-util-Arrays- import ja.pdfplease help finish sorting methods- import java-util-Arrays- import ja.pdf
please help finish sorting methods- import java-util-Arrays- import ja.pdf
ย 
Java Fundamentals
Java FundamentalsJava Fundamentals
Java Fundamentals
ย 
TechTalk - Dotnet
TechTalk - DotnetTechTalk - Dotnet
TechTalk - Dotnet
ย 
import java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdf
import java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdfimport java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdf
import java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdf
ย 
Python Session - 3
Python Session - 3Python Session - 3
Python Session - 3
ย 
Add an interactive command line to your C++ application
Add an interactive command line to your C++ applicationAdd an interactive command line to your C++ application
Add an interactive command line to your C++ application
ย 
python lab programs.pdf
python lab programs.pdfpython lab programs.pdf
python lab programs.pdf
ย 
DS LAB RECORD.docx
DS LAB RECORD.docxDS LAB RECORD.docx
DS LAB RECORD.docx
ย 

More from pratyushraj61

I need help getting my code to work (code is at the bottom)1.3.pdf
I need help getting my code to work (code is at the bottom)1.3.pdfI need help getting my code to work (code is at the bottom)1.3.pdf
I need help getting my code to work (code is at the bottom)1.3.pdf
pratyushraj61
ย 
I need an explanation on what the function of the number 1.428 in .pdf
I need an explanation on what the function of the number 1.428 in .pdfI need an explanation on what the function of the number 1.428 in .pdf
I need an explanation on what the function of the number 1.428 in .pdf
pratyushraj61
ย 
I need help coming up with a MIPS program for this.1.3. Overvi.pdf
I need help coming up with a MIPS program for this.1.3. Overvi.pdfI need help coming up with a MIPS program for this.1.3. Overvi.pdf
I need help coming up with a MIPS program for this.1.3. Overvi.pdf
pratyushraj61
ย 

More from pratyushraj61 (20)

helphelp Regarding the numerou.pdf
helphelp Regarding the numerou.pdfhelphelp Regarding the numerou.pdf
helphelp Regarding the numerou.pdf
ย 
Hello. Im having trouble trying to set the condition where once the .pdf
Hello. Im having trouble trying to set the condition where once the .pdfHello. Im having trouble trying to set the condition where once the .pdf
Hello. Im having trouble trying to set the condition where once the .pdf
ย 
Henrich is a single taxpayer. In 2022, his taxable income is $478,0.pdf
Henrich is a single taxpayer.  In 2022, his taxable income is $478,0.pdfHenrich is a single taxpayer.  In 2022, his taxable income is $478,0.pdf
Henrich is a single taxpayer. In 2022, his taxable income is $478,0.pdf
ย 
Hi could you focus on the isohyetal method and thiessen polygon me.pdf
Hi could you focus on the isohyetal method and thiessen polygon me.pdfHi could you focus on the isohyetal method and thiessen polygon me.pdf
Hi could you focus on the isohyetal method and thiessen polygon me.pdf
ย 
helpppppp((( The difference between an embedded object and a linked.pdf
helpppppp((( The difference between an embedded object and a linked.pdfhelpppppp((( The difference between an embedded object and a linked.pdf
helpppppp((( The difference between an embedded object and a linked.pdf
ย 
help on this thanks. Phalaropes are shore birds with brightly col.pdf
help on this thanks.  Phalaropes are shore birds with brightly col.pdfhelp on this thanks.  Phalaropes are shore birds with brightly col.pdf
help on this thanks. Phalaropes are shore birds with brightly col.pdf
ย 
I have an independent food delivery platform having a lot of differe.pdf
I have an independent food delivery platform having a lot of differe.pdfI have an independent food delivery platform having a lot of differe.pdf
I have an independent food delivery platform having a lot of differe.pdf
ย 
i need programingi need programing ai. Create o Va opplication t.pdf
i need programingi need programing ai. Create o Va opplication t.pdfi need programingi need programing ai. Create o Va opplication t.pdf
i need programingi need programing ai. Create o Va opplication t.pdf
ย 
I need help with making a program that can be part of a google forms.pdf
I need help with making a program that can be part of a google forms.pdfI need help with making a program that can be part of a google forms.pdf
I need help with making a program that can be part of a google forms.pdf
ย 
I need help fixing my assembly program please, I keep getting a segm.pdf
I need help fixing my assembly program please, I keep getting a segm.pdfI need help fixing my assembly program please, I keep getting a segm.pdf
I need help fixing my assembly program please, I keep getting a segm.pdf
ย 
I need help getting my code to work (code is at the bottom)1.3.pdf
I need help getting my code to work (code is at the bottom)1.3.pdfI need help getting my code to work (code is at the bottom)1.3.pdf
I need help getting my code to work (code is at the bottom)1.3.pdf
ย 
Hewitt Packaging Companynin ๏ฟฝdenmemi 14 kupon faiz oranyla 1.000 A.pdf
Hewitt Packaging Companynin ๏ฟฝdenmemi 14 kupon faiz oranyla 1.000 A.pdfHewitt Packaging Companynin ๏ฟฝdenmemi 14 kupon faiz oranyla 1.000 A.pdf
Hewitt Packaging Companynin ๏ฟฝdenmemi 14 kupon faiz oranyla 1.000 A.pdf
ย 
I need an explanation on what the function of the number 1.428 in .pdf
I need an explanation on what the function of the number 1.428 in .pdfI need an explanation on what the function of the number 1.428 in .pdf
I need an explanation on what the function of the number 1.428 in .pdf
ย 
I need help coming up with a MIPS program for this.1.3. Overvi.pdf
I need help coming up with a MIPS program for this.1.3. Overvi.pdfI need help coming up with a MIPS program for this.1.3. Overvi.pdf
I need help coming up with a MIPS program for this.1.3. Overvi.pdf
ย 
I need help being able to enable different voting types such as publ.pdf
I need help being able to enable different voting types such as publ.pdfI need help being able to enable different voting types such as publ.pdf
I need help being able to enable different voting types such as publ.pdf
ย 
I have this Koch Python code but isnt working. Can some please revi.pdf
I have this Koch Python code but isnt working. Can some please revi.pdfI have this Koch Python code but isnt working. Can some please revi.pdf
I have this Koch Python code but isnt working. Can some please revi.pdf
ย 
How do zoned reserves manage relations with local people1. Zone.pdf
How do zoned reserves manage relations with local people1. Zone.pdfHow do zoned reserves manage relations with local people1. Zone.pdf
How do zoned reserves manage relations with local people1. Zone.pdf
ย 
I have included the person.h file code. 1-4 In a file called functio.pdf
I have included the person.h file code. 1-4 In a file called functio.pdfI have included the person.h file code. 1-4 In a file called functio.pdf
I have included the person.h file code. 1-4 In a file called functio.pdf
ย 
I have a question regarding extreme value analysis.I fitted a gene.pdf
I have a question regarding extreme value analysis.I fitted a gene.pdfI have a question regarding extreme value analysis.I fitted a gene.pdf
I have a question regarding extreme value analysis.I fitted a gene.pdf
ย 
I concur, technology is so engrained in our day-to-day activities (w.pdf
I concur, technology is so engrained in our day-to-day activities (w.pdfI concur, technology is so engrained in our day-to-day activities (w.pdf
I concur, technology is so engrained in our day-to-day activities (w.pdf
ย 

Recently uploaded

Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
ย 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactistics
hameyhk98
ย 
Call Girls in Uttam Nagar (delhi) call me [๐Ÿ”9953056974๐Ÿ”] escort service 24X7
Call Girls in  Uttam Nagar (delhi) call me [๐Ÿ”9953056974๐Ÿ”] escort service 24X7Call Girls in  Uttam Nagar (delhi) call me [๐Ÿ”9953056974๐Ÿ”] escort service 24X7
Call Girls in Uttam Nagar (delhi) call me [๐Ÿ”9953056974๐Ÿ”] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
ย 

Recently uploaded (20)

21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
ย 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
ย 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
ย 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
ย 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
ย 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
ย 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health Education
ย 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
ย 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
ย 
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.
ย 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
ย 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactistics
ย 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
ย 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
ย 
Call Girls in Uttam Nagar (delhi) call me [๐Ÿ”9953056974๐Ÿ”] escort service 24X7
Call Girls in  Uttam Nagar (delhi) call me [๐Ÿ”9953056974๐Ÿ”] escort service 24X7Call Girls in  Uttam Nagar (delhi) call me [๐Ÿ”9953056974๐Ÿ”] escort service 24X7
Call Girls in Uttam Nagar (delhi) call me [๐Ÿ”9953056974๐Ÿ”] escort service 24X7
ย 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
ย 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
ย 
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
ย 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
ย 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
ย 

Here is my code for a linefile editor Please help me figure out wh.pdf

  • 1. Here is my code for a line/file editor: Please help me figure out when I input "E" to exit and save to the textin.txt file, it is not saving anything in textin.txt file. It also is prints "1>" twice when I hit enter before it will move on to "2>" See my output below and the needed output and I need the command "E" to save the output to the textin.txt file and terminate the program. "E" terminates my program, but is not saving to the txt file. import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class FileEdit { public static List lines = new ArrayList(); public static void main(String[] args) throws IOException { Scanner s = new Scanner(System.in); System.out.print("EDIT: "); String fileName = s.nextLine(); BufferedReader br = new BufferedReader(new FileReader(new File(fileName))); String str=""; int count=0; while((str=br.readLine())!=null) { lines.add(count, str); System.out.println((++count) + "> "+ str); } String text=""; String command = ""; System.out.print((++count)+"> "); command=s.nextLine(); String commandArr[]; int flag; while(!command.equals("E")) {
  • 2. flag=0; commandArr = command.split("s"); if(commandArr[0].equals("I")) //Insertion { while(true) { if(commandArr.length==1&&flag!=2) { System.out.print((count)+"> "); text = s.nextLine(); insertLine(text,count-1); } else if(commandArr.length==2&&flag!=2) { System.out.print((commandArr[1])+"> "); count=Integer.parseInt(commandArr[1]); text = s.nextLine(); insertLine(text,Integer.parseInt(commandArr[1])-1); } else insertLine(text,count-1); System.out.print((++count)+"> "); command=s.nextLine(); commandArr = command.split("s"); if(commandArr[0].equals("I")||commandArr[0].equals("L")||commandArr[0].equals("D")||comm andArr[0].equals("E")) { flag=1; break; } else { flag=2; text=command; } }
  • 3. } else if(commandArr[0].equals("L")) //Listing { printList(); } else if(commandArr[0].equals("D")) //Deletion { if(commandArr.length==1) { deleteLine(count-1,count-1); } else if(commandArr.length==2) { deleteLine(Integer.parseInt(commandArr[1])-1,Integer.parseInt(commandArr[1])-1); } else if(commandArr.length==3) { deleteLine(Integer.parseInt(commandArr[1])-1,Integer.parseInt(commandArr[2])-1); } count=lines.size(); } if(flag!=1) { System.out.print((count++)+"> "); command = s.nextLine(); } } } public static void insertLine(String text,int count) { if (count >= lines.size()) { for(int i = lines.size(); i <= count; i++) { lines.add(null); } } lines.set(count,text);
  • 4. } public static void deleteLine(int start,int end) { for(int i=start;i<=end;i++) lines.remove(i); } public static void printList() { for(int i=0;i "+lines.get(i)); } } Here is the output I am getting: EDIT: textin.txt 1> The First Line 1> 2> And another line 3> I 3 3> The second line 4> One more line 5> L 1> 2> 3> The second line 4> One more line 5> D 2 3> L 1> 2> The second line 3> One more line 4> E Output needed and "E" to save to txt file and terminate program: 1> The first line 2> 3> And another line 4> I 3
  • 5. 3> The second line 4> One more line 5> L 1> The first line 2> 3> The second line 4> One more line 5> And another line 5> D 2 4> L 1> The first line 2> The second line 3> One more line 4> And another line 5> E