What's the easiest way to remove a line of a textfile?

The line to remove can be any line in the file - not only the first or last one. How can I insert or append a line to a textfile?
Is there any good tutorial for file operations?
Thanks a million,
Serano.

If you wish to remove any line inside of a text file, you're going to have to use random access. The documentation for the class is located here:
http://java.sun.com/j2se/1.3/docs/api/java/io/RandomAccessFile.html
If you wish to append to a text file, you can use FileWriter. If you pass a boolean of value true as the second argument to the constructor, it will append to the file.

Similar Messages

  • What is the easiest way to remove duplicate contacts on my Iphone?

    What is the easiest way to remove duplicate contacts on my Iphone and avoid them in the future?

    There are apps that will locate and remove duplicate contacts, such as My Contacts Backup Pro.  As for preventing them in the future, if you are syncing contacts both with iTunes and iCloud this will create duplicates.  If you are, pick one and disable the other.

  • What's the easiest way to remove/append a line of a text file???

    The line to remove can be any line in the file - not only the first or last one.
    Is there any good tutorial for file operations?
    Thanks a million,
    Serano.

    To remove a line from a text file, the easiest way is to read it in one line at a time and write out all lines except the one you want to remove to a new version of the file. Likewise, to insert a line, you read the file one line at a time and write the lines to a new version, inserting the new line at its correct spot.

  • What is the easiest way to remove the fast foward button from the play bar?

    Everytime a user clicks on the fast foward (not the forward) it screws up the audio. It doesnt really serve an purpose in my CBT so I would like to just remove it. Is there an easy way?

    you don't indicate what version you're using, but in Cp5.5 (and I presume it's similar in Cp6), go to Project > Skin Editor, then uncheck the buttons you don't want.

  • What is the easiest way to delete a line in a file?

    Hi!
    I have a file that is line oriented. I am using BufferedReader and BufferedWriter. My problem is, is how do I easily delet a line from a file? Sort of like this:
    This
    is
    not
    a
    file
    To:
    This
    is
    a
    file
    My file then has to be resaved like that.

    That was my idea what you did. Just making sure their
    was no other way. There are surely other ways to do it.
    As the file is dynamic, I have no
    Idea how many lines long it is. Thank you.But you have not just an idea but the exact size of file!
    That's just an example:import java.io.*;
    class X {
         private static final String BAD_LINE = "so bad!";
         private static final String NEW_LINE = System.getProperty("line.separator");
         public static void main(String[] args) throws IOException {
              File f = new File("filename");
              //supposing in "worst" scenario nothing will be removed
              StringBuffer sb = new StringBuffer((int)f.length());
              String line = "";
              BufferedReader in = new BufferedReader(new FileReader(f));
              while((line = in.readLine()) != null) {
                   //just filter out good lines
                   if(!line.equals(BAD_LINE)) sb.append(line + NEW_LINE);
              in.close();
              //write back the processed file:
              BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream("filename"));
              byte[] bout = sb.toString().getBytes();
              out.write(bout, 0, bout.length);
              out.close();

  • What's the easiest way to back up and restore my hard drive to a new HD

    I'm going to upgrade my hard drive to a larger one on my MacBook. I have an external backup drive. What is the easiest way to save all my data (documents, emails, etc) and applications and restore them to the new hard drive in my MacBook? I have Leopard OS.
    I've read on the forum everything from using Time Machine to the Disk Utility. I have been backing up everything to my external HD using Time Machine.
    Can you point me to a step by step process.

    I don't use TM, so here's my method that I've used many times for the same thing you are doing.
    How to Clone Using Restore Option of Disk Utility
    1. Open Disk Utility from the Utilities folder.
    2. Select the backup or destination volume from the left side list.
    3. Click on the Erase tab in the DU main window. Set the format type to Mac OS Extended (journaled, if available) and click on the Erase button. This step can be skipped if the destination has already been freshly erased.
    4. Click on the Restore tab in the DU main window.
    5. Select the backup or destination volume from the left side list and drag it to the Destination entry field.
    6. Select the startup or source volume from the left side list and drag it to the Source entry field.
    7. Double-check you got it right, then click on the Restore button.
    Now, boot from the clone to be sure it works correctly by opening Startup Disk, selecting the external volume, then clicking the Restart button. If all is well the computer will boot from the external drive. Now shut down the computer and disconnect the external drive. Disconnect the AC adapter and remove the battery. Install the new hard drive. Once you've completed the installation connect the external drive and restart the computer.
    Now do the following:
    Extended Hard Drive Preparation
    1. Open Disk Utility in your Utilities folder. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Installer menu (Utilities menu for Tiger or Leopard.)
    2. After DU loads select your new hard drive (this is the entry with the mfgr.'s ID and size) from the left side list. Note the SMART status of the drive in DU's status area. If it does not say "Verified" then the drive is failing or has failed and will need replacing. SMART info will not be reported on external drives. Otherwise, click on the Partition tab in the DU main window.
    3. Click on the Options button, set the partition scheme to GUID (only required for Intel Macs) then click on the OK button. Set the number of partitions from the dropdown menu (use 1 partition unless you wish to make more.) Set the format type to Mac OS Extended (Journaled.) Click on the Partition button and wait until the volume(s) mount on the Desktop.
    4. Select the volume you just created (this is the sub-entry under the drive entry) from the left side list. Click on the Erase tab in the DU main window.
    5. Set the format type to Mac OS Extended (Journaled.) Click on the Options button, check the button for Zero Data and click on OK to return to the Erase window.
    6. Click on the Erase button. The format process will take 30 minutes to an hour or more depending upon the drive size.
    Steps 4-6 are optional but recommended for a drive that has never been formatted before, if the format type is not Mac OS Extended, if the partition scheme has been changed, or if a different operating system (not OS X) has been installed on the drive.
    After formatting is completed use DU to clone the external drive's system back to the new internal drive. The external drive becomes the Source and the internal drive will be the Destination.

  • Fonts - What's the easiest way to do this?

    Hi All,
    I'm in a situation at the moment where I would like to put the JDK 1.4 fonts into a JDK 1.3 program..
    What's the easiest way to do this?

    Hi,
    perhaps you can get no answer, because it is not clearly said, what you want to do?- From which JDK 1.4 Fonts are you talking of?- What is meant by this?- The Font class or what else?- Do you want to replace one or more .class files of JDK 1.3 by one of JDK 1.4?
    In general you are not allowed to replace parts of the packages or subpackages of "java", "javax" or "sun" or add or remove classes to resp. from them - you accepted this terms when you had downloaded the JDK - sure, it is possible, but you are not allowed to do so - it is illegal.
    greetings Marsian

  • What's the easiest way to transfer files to new mac?

    My first mac was a Macbook (purchased in August 2010) and I'm upgrading to the new 13" Macbook Pro with retina display. What is the easiest way to:
    1) transfer files to the new laptop
    2) delete files off my old macbook to share with a family member--possibly thinking of return to factory settings.
    I have a 1TB external hard drive and I use the cloud on all of my devices (also have iPhone and iPad synched to the cloud).

    Welcome to Apple Support Communities
    1. The best way to transfer files from another computer is by using Migration Assistant > http://pondini.org/OSX/SetupLion.html Your new MacBook Pro will ask you to restore from another computer during its initial setup.
    2. If you haven't got a lot of apps you installed, you can just create a new user and delete the old one, so you won't have to reinstall Mac OS X.
    To do it, open System Preferences > Users and Groups (or Accounts), press the + button and create an admin user. Then, log in this user, go to System Preferences > Users & Groups, and remove the old account

  • What's the easiest way to manage my music on my iPhone 4S, espeially to delete duplicates

    It is difficult for to manage playlists, smart playlists and restored playlists. What is the easiest way to go through my 7.9 Gigs of music on the iphone and remove duplicates. Is there a way to do this on the phone itself or do I have to go through syncing?

    Hello ihweiner,
    Thanks for using Apple Support Communities.
    For more information on this, take a look at:
    How to find and remove duplicate items in your iTunes library
    http://support.apple.com/kb/ht2905
    Best of luck,
    Mario

  • I am using Iphoto 11 ver 9.4.3 on mac using oxs 10.8.5 i want to export calendar projects to an external hard drive. what is the easiest way to do this? i have tried export and import but it didn't seem to work.

    I am using Iphoto 11 ver 9.4.3 on mac using oxs 10.8.5 i want to export calendar projects to an external hard drive. my goal is to store them in an external hard drive so it doesn't use up memory on the mac hard drive. is it possible to copy the specific projects without copying the entire library? what is the easiest way to do this? i have tried export and import but it didn't seem to work.

    What do you not understand?
    You can duplicate the iPhoto library (command - D ) and delete everything except the project and its photos from the copy and move that
    Or
    However the calendar takes very little space - it is simpy database entries - it is the photos in the calendar that take space - and for most people you would wnat to keep those photos in your library
    you can use a photo in 50 calendars and it still is only one photo in your library - as I explained calenders do not exist as such - they are simply database entries telling iPhotop how to display the calendar - they take almost no space at all
    LN

  • What is the easiest way to create and manage very big forms?

    I need to create a form that will contain few hundred questions. Could you please give me some advise on what is the easiest way to do that? I mean for example is it easier to create everything in Word (since it is easier to manage) and than create a form based on that?
    My concern is that when I will have a very big form, containing different kinds of questions and with many scripts, managing it during work will be slow and difficult, for example adding a question in the middle of the form which would require moving half of the questions down which could smash the layout etc.
    What is the best practise for that?
    Thanks in advance

    Try using Table and Rows for this kind of forms. These forms will have the same look throught with a question and and answer section..
    In the future if you want to add a new section, you can simply add rows in between..
    Thanks
    Srini

  • I want to use 1 itunes account but with 3 different iphones 2 for the kids and one for me, what is the easiest way to do that?

    I want to use 1 itunes account but sync 3 different iphones, 2 for the kids and 1 for me.  So I would like to have different programs, songs, apps etc for each phone.  What is the easiest way to do that

    Agreed heather. Also, if you have three users on the same account how do you keep phone calls and messages from going to all three phones?

  • I have a mid year 2007 24 inch iMac and will be purchasing a new 27 inch Retina iMac, what is the easiest way to transfer the data and files from my old machine to the new one?

    I have a mid year 2007 24 inch iMac and will be purchasing a new 27 inch Retina iMac, what is the easiest way to transfer the data and files from my old machine to the new one?

    Following up on this thread,
    I have a new iMac on the way and my current is from 2008, never had a problem but I am sure there are internal issues that I would prefer not to transfer.
    I have no issues other then the slowness in certain programs and that is the main reason to buy a new one.
    Programs like numbers and pages seem to take a longer time to open after I update to Yosemite.
    I only use 272GB of 500 GB, my memory is 4GB and I am upgrading to 8Gb and bought the 4.0 processor.
    Question:
    Is there a way to manually transfer items or would that be a waste of time in that if there are issues they could be anywhere and would transfer anyway?

  • What is the easiest way to burn imovies onto DVD's.   I want to burn more than one movie onto DVD as I create.    Can I continue to burn onto the same DVD as the movies are created?

    What is the easiest way to burn my imovies onto DVD's?    I want to burn movies as I create them and then continue to add more movies to the same DVD as the years go by -- until the DVD is full!    Is this possible?

    You might also want to post this in the iMovie forum https://discussions.apple.com/community/ilife/imovie

  • What is the easiest way to transfer a large imovie project from one computer to another in a different location.

    What is the easiest way to transfer an faairly large HD imovie project from one computer to another in a different location. Can you export to drop box? Will the other computer need the exact imovie version?

    OK it depends.
    If you have a finished movie, you can SHARE/EXPORT MOVIE and create your final movie. Then, depending on the size of the finished movie, you can transfer via dropbox or similar service. Ninety minutes is a very long movie for iMovie, but it may work for you. I would suggest 720P to keep the size down.
    If you need to transfer the entire iMovie Project so it can be edited in iMovie at the other end, then you need to transfer the project and event assets to an external hard drive and get the hard drive to the other location.
    Directions are here. Follow the directions for 1) Moving or copying Project to external drive. Then 2) Consolidate Media.
    https://discussions.apple.com/docs/DOC-4141

Maybe you are looking for

  • BAPI for Creation of Inbound delivery Document

    Hi I have found a BAPI for Creating Inbound delivery Document, BBP_INB_DELIVERY_CREATE. I filled the below parameters and executed it. IS_INB_DELIVERY_HEADER          DELIV_DATE                     11.04.2007                            IT_INB_DELIVER

  • AC adapter light not working

    When charging my Macbook Pro sometimes the indicator LED light doesn't come on at all.  Everytime I checked when the LED isn't working the computer still charges, but I am not sure if when I leave it sometimes if it is charging correctly since the LE

  • Can i view movies and pictures stored ona Time Capsule using Apple TV

    Can I view movies and pictures and listen to music that have been stored on a Time Capsule using my Apple TV?

  • KM_RKM SQL LDAP (JYTHON).xml

    Hello, I am using the reverse engineering module. The tables are correctly retrieved. The columns aren't. This might be the caused by: clst = self.metadata.getColumns(self.srccatalog, self.srcschema, tablename, '%') I get messages in the log resultin

  • Upgrade 2 basic lines to smartphones and add a smartphone line

    I have 3 lines we are on a family share plan and line 1 is the only smartphone. Line 1 unlimted data smartphone line 2 and 3 are due for upgrades just basic phones but want to switch to smartphones plus add a 4th line.  do I have to give up my unlimt