delete lines in the file

delete lines in the file

I am using a file as Input in program...The file contains round about 1,00,000 lines .My program after each iteration takes a data from that file at process it. My Question is when a particular data is used once it will not be used any further .In one word i want to skip that data in the subsequent iteration... My solution was to copy the data that was not used is copied in another temporary file and that file is renamed to the original file .Here the time complexity increases rapidly and I want to avoid it.. Thanks for the reply in advance!!!!

View Answers

August 28, 2013 at 4:09 PM

Hi,

There is not method to remove the line without using the temp file. Since you are processing a big file you can't use the temp file. The better way is to read file line by line and the process the data.

You may also store the line no as parameter in your program and the process the remaining lines your program.

View the tutorial of Reading file line by line.

Thanks


August 28, 2013 at 11:15 PM

your suggestion is to store the line-no in a arraylist an then each time it will check whether the lone number in the ArrayList or NOT!...









Related Tutorials/Questions & Answers:
delete lines in the file
delete lines in the file   I am using a file as Input in program...The file contains round about 1,00,000 lines .My program after each iteration takes a data from that file at process it. My Question is when a particular data
delete lines in the file
delete lines in the file   I am using a file as Input in program...The file contains round about 1,00,000 lines .My program after each iteration takes a data from that file at process it. My Question is when a particular data
Advertisements
delete lines in the file
delete lines in the file   I am using a file as Input in program...The file contains round about 1,00,000 lines .My program after each iteration takes a data from that file at process it. My Question is when a particular data
display repeated lines in a file
display repeated lines in a file  i want a java program that accepts file from user and displays the repeated lines in a file
Delete specific lines from text in Java
Delete specific lines from text in Java  Hi, beginning in java, i'm trying to delete specific line from a text file. Ex: i want to delete data... number that i want to delete. how could it be possible with java. thanks a lot
Search and return lines of text file
Search and return lines of text file  I wrote the following code, that found lines of txt file with contains certain word, but it returns only the first or the last line! (However, the System.out.println show me all the lines
Read Lines from text file
need to do this for a file with 11 lines. Here's my code while((line...Read Lines from text file  Here's a brief desc of what my Java code does .. I'm using BufferedReader to read lines from a text files and split each
Java read lines from file
Java read lines from file  Any code example related to Java read lines from file? In my project there is requirement of reading the file line by line... of reading file line by line in Java. Can any one share me the code for reading
Java file number of lines
Java file number of lines In this section, you will learn how to count the number of lines from the given file. Description of code: Java has provide... of the file. We have used counter here to detect the number of lines occurred
delete a file - JSP-Servlet
delete a file  Correct question::::How can we delete a file which is stored in a server when read write operations for this particular file is closed.  http://www.communigate.com/CommuniGatePro/WebFiles.html
Java delete file if exists
Java delete file if exists  Hi, Hi how to delete file if exists? I need example code of java delete file if exists. Thanks   Hi, following code can be used: String tempFile = "C:/mydir/myfile.txt"; //Delete
delete a file - JSP-Servlet
delete a file  How can we read a file which is stored in a server when read write operations for this particular file is closed
Count lines of a particular file
In this program you will learn how to read a file and count number of lines... and count no of lines in a file. Program first asks the user to enter.... Its reads the file(s) and then prints the no of lines in each file. Java
Java file delete
Java file delete In this section, you will learn how to delete a file... we are going to delete a file. For this, we have created an object of File and call the method delete() through the object. This method delete the file from
How to delete file in Java code?
How to delete file in Java code?  Hi, From my Java program I have to delete a file. How to delete file in Java code? Thanks   Hi, Java API provides methods for deleting a file in Java. You can use the delete
To dump 10lakh lines from a text file to a mysql table
To dump 10lakh lines from a text file to a mysql table  I need to dump a text file datas -100000 lines into a mysql table.i'm able to dump only 152000 lines only
How to delete file in java ?
How to delete file in java ? In this section we will learn how to write a program to delete a file in java. You can delete the file or folder, java File class provide two methods: delete(path) : This method delete the file or throw
java - file delete - Java Beginners
java - file delete  I will try to delete file from particular folder...){ try { File delete = new File (incurrentFile); System.out.println... following code to delete a file from the folder import java.io.File; public
java - file delete - Java Beginners
java - file delete  I will try to delete file from particular folder...){ try { File delete = new File (incurrentFile); System.out.println... will try to delete these files. But it doesn?t delete from this folder. My code
How to delete .xlsx file in java?
How to delete .xlsx file in java?  Hello Sir, I am unable to delete .xlsx file using below code, What is wrong here? if(myFile != null && myFile.exists()    && myFile.canRead() &&
in unix which command is used to sort the lines of data in a file in reverse order
in unix which command is used to sort the lines of data in a file in reverse order  in unix which command is used to sort the lines of data in a file... the lines of data in a file in reverse order
J2ME delete file - Java Beginners
J2ME delete file  How do i delete a textfile on a mobile phone using j2me?  Hi Friend, Please visit the following link: http://www.roseindia.net/j2me/ Hope that it will be helpful for you. Thanks
C file delete example
C file delete example       This section illustrates you to delete a file in C. You can see in the given example that we want to remove the file HELLO.txt. For this, we have
Delete and edit data in xml file using JSP
Delete and edit data in xml file using JSP   I want to know how to delete and edit data from an XML file by use of JSP. I have XML file having tasks... in the xml file,I want to delete and edit some tasks using task id then how can i do
Delete a file from FTP Server
In this section you will learn how to delete file from FTP server using java
How to delete excel file records using Store Procedure?
How to delete excel file records using Store Procedure?  Hi.. I have created one Excel file through stored procedure.Now I want to delete records or delete excel file. Thanks
Delete a File
DeletingFile Enter the file name to delete:wonderful.txt File... Delete a File    ... a specified file or directory is deleted. For deleting a file from a directory you need
Java Read Lines from Text File and Output in Reverse order to a Different Text File
Java Read Lines from Text File and Output in Reverse order to a Different Text File  I need to read a file that was selected by the user using the JButton. Each line in the file then needs to be converted in Reverse Order
how to delete a jar file from mobile by using j2me program.
how to delete a jar file from mobile by using j2me program.  When i'll update a new version jar in mobile. Then i want to delete that old jar which is previously present in mobile. How to do
How to delete content of a log file from linux terminal?
How to delete content of a log file from linux terminal?  Hi, My... running queries. But first I want to delete the content of the /var/log/slow-queries.log file. Can anyone tell me how to do this? Thanks   Hi, Its
DELETE
DELETE   I AM DOING IT IN MYSQL. DELETE FROM EMP WHERE SAL>(SELECT SAL FROM EMP WHERE ENAME='MILLAR') AND ENAME='ALLEN'; THIS IS GIVING THE FOLLOWING ERROR Error Code : 1093 You can't specify target table 'EMP
How to delete a character from a file in java - Java Beginners
How to delete a character from a file in java  I'm not gettting how to remove a character from a file in java....could any one help me out?? ... to read each and every character from file and check for the required string
delete
delete  how delete only one row in the database using jsp.database...;td><input type="button" name="edit" value="Delete" style="background-color..."); Statement st = conn.createStatement(); st.executeUpdate("DELETE FROM employee
Java file delete fails
Java file delete fails This section demonstrates you how the deletion of file... fails. There may be some reasons for this like the file you want to delete, does... application. So before going to delete a file, check whether the file exists
Delete file or Directory
Delete file or Directory      ... we want to delete. The given program deletes an existing file if the file... are creating a delete() method. In this method first we are creating a file object
Delete temp file
Delete temp file      ... whether it does exist or not. When the file is exist, it will delete the specified... that is used to delete a file which have to be deleted and terminates the virtual machine
delete retailer jsp file (sir..is this a good logic.. jsp file is useful for what purpose)
delete retailer jsp file (sir..is this a good logic.. jsp file is useful... want to delete retailer?") }*/ } </script> </head> <body> <div id="page-heading"><h1>Delete Retailer</h1></div>
Ajax Lines
Ajax Lines       A pretty extensive list of AJAX resources, tutorials, toolkits and websites. List of all useful and interested resources that may help for AJAX development. Collection
ModuleNotFoundError: No module named 'lines'
ModuleNotFoundError: No module named 'lines'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'lines' How to remove the ModuleNotFoundError: No module named 'lines'
Java file line count
Java file line count In the section, you will learn how to count the number of lines from the given file. Description of code: Java has provide various... the number of lines occurred in the file.  hasNextLine(): This method
Delete Account
Delete Account  How to delete account
Java - Deleting the file or Directory
= new File(file); and delete the file using delete function f1.delete(); which... Java - Deleting File       Introduction In this section, you will learn how a specified file
ModuleNotFoundError: No module named 'lines-table'
ModuleNotFoundError: No module named 'lines-table'  Hi, My Python... 'lines-table' How to remove the ModuleNotFoundError: No module named 'lines-table' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'method-lines'
ModuleNotFoundError: No module named 'method-lines'  Hi, My Python... 'method-lines' How to remove the ModuleNotFoundError: No module named 'method-lines' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'edgy-lines'
ModuleNotFoundError: No module named 'edgy-lines'  Hi, My Python... 'edgy-lines' How to remove the ModuleNotFoundError: No module named 'edgy-lines' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'json-lines'
ModuleNotFoundError: No module named 'json-lines'  Hi, My Python... 'json-lines' How to remove the ModuleNotFoundError: No module named 'json-lines' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'lines-overlap-s528358'
ModuleNotFoundError: No module named 'lines-overlap-s528358'  Hi...: No module named 'lines-overlap-s528358' How to remove the ModuleNotFoundError: No module named 'lines-overlap-s528358' error? Thanks   Hi
ModuleNotFoundError: No module named 'sample-lines'
ModuleNotFoundError: No module named 'sample-lines'  Hi, My Python... 'sample-lines' How to remove the ModuleNotFoundError: No module named 'sample-lines' error? Thanks   Hi, In your python
To delete post
To delete post  How can I delete my old post answer. I've posted 2 same answers by mistake
delete jsp
delete jsp  <%@ page language="java" contentType="text/html...; charset=ISO-8859-1"> <title>Delete Student</title> </head>...;/Controller"> <input type="hidden" name="page" value="delete"/> <

Ads