Reading a file and changing one part of the file

I am trying to read a file and then I want to change the first value on each line. The file I am reading is a .HEADER file. Which is just read in notepad I am just opening this like a txt file. I get no say at all how this file is created originally
I want to change the value on the first line the a new title plus the ext .dat. The file is below. This stays the same format just with different values.
ECG000 1 171 26112 9:14:56 23/04/2002
ECG000 8 43(0) 8 127 79 -24066 0 AED trace
I want to change the ECG000 to a new value eg Pat1.dat on the first line and Pat1 on the second line. When I read this file in and output to the dos window I get ECG000 0 0 0 and that is it. Any ideas why this is happening and how I can replace the values in the file??
     private void FileExt() throws IOException
          System.out.println("In function");
          BufferedReader br = new BufferedReader(new FileReader("c:\\Projects\\FirstSupport\\ECG000.HEADER"));
          String s;
          Vector data = new Vector();
          ECGFile = new FileWriter("c:\\Projects\\FirstSupport\\ECG.txt",true);
          System.out.println("Reading the file");
          while ((s = br.readLine()) != null)
          data.add(s);
          System.out.println(s);
          System.out.println("Finished");
          String label = s.substring(0, s.indexOf(" "));
          System.out.println(label);
          String newLabel = (label+".dat");
          System.out.println(newLabel);
     }

I think this is what you're looking for:     private void FileExt() {
          java.util.List data=new ArrayList();
          String s;
          try {
               BufferedReader br=new BufferedReader(new InputStreamReader(
                    new FileInputStream(new File("ECG000.HEADER"))));
               while ((s = br.readLine()) != null)  {
                    data.add(s);
                    System.out.println(s);
               br.close();
          catch (FileNotFoundException fnfe) {
               System.out.println("Input file not found");
               return;
          catch (IOException ioe) {
               ioe.printStackTrace();
               return;
          ListIterator li=data.listIterator();
          try {
               PrintWriter ECGFile=new PrintWriter(new FileOutputStream(
                    new File("ECG.txt")));
               while(li.hasNext()) {
                    s=(String)li.next();
                    if (s.substring(0, 6).equals("ECG000")) {
                         s="Pat1.dat"+s.substring(6, s.length());
                    ECGFile.println(s);
               ECGFile.close();
          catch (FileNotFoundException fnfe1) {}
     }Mark

Similar Messages

  • I have problem with Itunes losing where podcasts and some purchased music is located. Don't know how Itunes losing the locations of the files and I can't find the files on my hard drive. What can I do to stop Itunes losing location and restore my files?

    I have problem with Itunes losing where podcasts and some purchased music is located. Don't know how Itunes losing the locations of the files and I can't find the files on my hard drive. What can I do to stop Itunes losing location and restore my files?

    Try assigning Queen as the Album Artist on the compilations in iTunes on your computer.

  • I am trying to make a pdf of a file and I need to get the file size to be no bigger than 10MB. What is the best way to do this

    I am trying to make a pdf of a file and I need to get the file size to be no bigger than 10MB. Even when I save it, the image quality at minimum the file size is 10.9 MB. What is the best way to do this

    @Barbara – What purpose is that PDF for? Print? Web?
    If web purpose, you could convert CMYK images to sRGB. That would reduce the file size as well.
    A final resort to bring down file size is:
    1. Print to PostScript
    2. Distill to PDF
    That would bring file size down even more. About 20%, depending on the images and other contents you are using, compared with the Acrobat Pro method. If you like you could send me a personal message, so we could exchange mail addresses. I could test for you. Just provide the highres PDF without any downsampling and transparency intact. Best provide a PDF/X-4.
    I will place the PDF in InDesign, print to PostScript, distill to PDF.
    Uwe

  • When I download files, firefox is adding " .part " to the file name and the file won't open, but if i back the .part out, it opens fine.

    Firefox seems to be adding " .part " to the file names of files I downoad. Here's an example:
    YuT9iNv8.pdf.part
    I cannot open this file because it can't find an application.
    If I back out the .part, I get a box asking if I want to change the extension to .pdf I check yes, and everything works fine. It doesn't happen with other browsers (Safai).

    I get the error message saying the file could not be downloaded due because there is no enough disk space.
    How large is your HD and how much space do you have left?

  • Reading a File by Knowing a part of the file name

    Hi Java Gurus,
    Can I copy a file to another location by knowing a part of the file name.I know the extension of the file and part of the file name.Can I copy such a file to another directory?
    Eg :
    0099999999_JAPPLIC_20090320.pdf is the file name.
    I know the file name contains 'JAPPLIC' .Can I use this clue and the extension of the file to copy the file to another directory.
    Please let me know whether it is possible or not.
    Regards,
    Rakesh.

    Hi ,
    I used the below code and I was able to solve the problem.I was able to select the files of the required extension and serach for the file names containing the text I know and use such files and move to another directory.It may be helpfulk to you people
    public class FileDeletion {
    public static void main (String args[]) {
         String e = "";
         String d = "C:\\TCCTouchpoints\\Attachments_Export\\outbound";
         String newFileLoc = "C:\\TCCTouchpoints\\Attachments_Export\\move";
    ExtensionFilter filter = new ExtensionFilter(e);
    File dir = new File(d);
    File newLoc = null;
    String[] list = dir.list(filter);
    if (list.length == 0) return;
    System.out.println("File Length "+list.length);
    ArrayList fileNames = new ArrayList();
    for (int i = 0; i < list.length; i++) {
    /*file = new File(d + list);
    boolean isdeleted = file.delete();
    System.out.print(file);
    System.out.println( " deleted " + isdeleted);*/
         System.out.println(list[i]);
         if(list[i].contains("_F5029.03_")){
              fileNames.add(list[i]);
              //System.out.println(list[i]);
    dir = null;
    for(int i=0;i<fileNames.size();i++){
         dir = new File(d+"\\"+fileNames.get(i));
         newLoc = new File(newFileLoc+"\\"+fileNames.get(i));
         if(dir.renameTo(newLoc)){
              System.out.println(dir + " is moved to "+ newLoc);
         }else {
              System.out.println("***** " dir " is not moved to "+ newLoc);
         dir = null; newLoc = null;
    for(int i=0;i<list.length;i++){
         dir = new File(d+"\\"+list[i]);
         dir.delete();
    class ExtensionFilter implements FilenameFilter {
    private String extension;
    public ExtensionFilter( String extension ) {
    this.extension = extension;
    public boolean accept(File dir, String name) {
    return (name.endsWith(extension));
    Thanks for replying .......

  • How can I transfer my iTunes Media Library from one PC to another without losing files and making a mess of the file and album structure?

    I have imported a number of Café del Mar CD's to iTunes, and iTunes keeps scattering the tunes into several different folders in iTunes Media. It also has trouble finding album information, unless it has been downloaded from iTunes Store. Previous versions of iTunes I have tried didn't have this problem.
    I've tried to tidy the files manually in iTunes Media, but that usually results in duplicates, so I stopped messing with it. I actually wouldn't mind iTunes blowing up my albums into a nightmare file structure of hyper categorization in iTunes Media (Album, Album Artist, Artist, etc.) if only it recognised its own mess when I transfer the library from one iTunes library into another.
    An example: I downloaded Cafe del Mar - Essential Elements featuring 13 tunes, two of these can be found in the files Cafe del Mar/Cafe del Mar Essential Elements, iTunes also created the folder Cafe del Mar/Cafe del_Mar Essential Elements containing 0 tunes!?! and the rest of the tunes are found under Rue de Soleil in the root folder, indicating ONE of the artists as the criteria for creating a folder of tunes!?!
    I am trying with every fiber NOT to hate this program, and would appreciate it if someone could explain to me how I can move an iTunes Media library of aprox 54 gb from my desktop via an external harddisk onto my laptop. I have tried 4 times, and everytime the result varies. Sometime I transfer 3000 files, other times 4000. Which files follow and don't is random. I lose files tranferring to the external harddisk and lose even more files from the external disk to the new library on my Lap. Do I have to transfer song for song or can this genius program actually transfer a larger amount of files without losing half the files and duplicating the rest?
    Is there a limit of size or amount of files?

    Backup with this User Tip, restore the library to the new computer using the same tool, keep the backup up-to-date in future. Deauthorize the old computer if you no longer need to access protected content on it.
    As to your issues with compilations albums select all the tracks, set the Album Artist to Various Artists and on the options tab set Part of a compilation to Yes. See Grouping tracks into albums for details.
    tt2

  • I downloaded ITunes and now I tried to open the file, and it is not supporting the file

    I downloaded ITunes on my galaxy s4 and tried to open the file and it says it is not supported

    Errr, this is a Adobe Lightroom user to user forum, do you have a question about Lightroom?

  • Upgrading 6.5 webi files and universe to XI - will the files load directly....

    Post Author: wstromer
    CA Forum: Migration to XI R2
    Can a set of BO 6.5.1 .wid files and universe files import directly into a BO XI server? If not then what is the process to upgrade these to a XI environment? Thanks for any help.

    Post Author: TAZ
    CA Forum: Migration to XI R2
    If by direct you mean copied then no. They must be migrated.
    The proper tool to do this is the import wizard. Usually it's best to avoid migrating security (due to the massive changes between versions)
    If you run into difficulties you can open a case with the deployment team.
    Regards,
    Tim

  • Aperture: How can I batch change one part of a file name

    I have a file name format for my motor sport pictures
    EventNameYear_CarNumber_ImageNumber
    I have just named 600+ images but after publishing the images, I spotted I put the event year as 2014 instead of 2015.
    How can I batch change the year but leave everything else the same? I've been through the batch change options but cannot work it out
    I am on Aperture 3.6, MacBook Pro on Yosemite 10.10.2
    Thanks

    So you renamed the versions in Aperture, the rename was not just done on the export?
    The names could be changed either in Aperture or on the exported files but as was noted it would require a script to do it. Doing the rename on the exported files would be the easiest, Applescript or possibly even Automator or any number of 3rd party apps could handle this rather easily. Name Mangler comes to mind as possibly being able to handle this.

  • I do not have a custom ringtone folder in my iphone 5.  I have gone to settings ringtones and there is no folder. In iTunes I have created the file and changed to M4r.  The song is less than 20 seconds.  I have synced my iPhone with iTunes but no folder.

    How do I make a folder in my Iphone 5 for custom ringtones?
    I have made it a m4r file that is less than 30 sec. Synced phone with the latest version of iTunes.  They show up in itunes as custom ringtones but there is no folder on my iPhone 5. Thanks!!!

    ping209 wrote:
    Yes it is> Does that make a difference?
    Yes, it has to be smaller than 35 seconds.
    Enjoy your ringtone.

  • Using cfhttp to read a page and write its contents to a file.

    Hi,
    I am trying to get a feed of my ebay store listings to load
    into froogle. Unfortunately, ebay provides the feed as a website
    not a file and froogle (via GoogleBase) needs the file to be
    submitted as an XML file.
    Is there a way to use something like cfhttp to load up the
    page where the feed is located, scan the page and write it's
    contents into an XML file that I can then load up to GoogleBase???
    thanks for the help.

    ignore me now.... I answered my own question a short while
    ago.
    for anyone who cares....
    I used CFHTTP to get the page and then used a cffile to write
    the #cfhttp.filecontent# into the new file!

  • InDesign Crashed and Now Can't Open the File It Crashed On

    I had a file open from a G4 server. I left and came back and my computer had gone to sleep losing the connection to the server. InDesign crashed with that file open and now I can't open the file at all I keep getting this error message:
    Cannot open the document [document name]. You may not have permission or the document may be open already. For multi-user access, close the file and then lock it using the File > Get Info command in the Finder.
    The document is not open, on the server I forced the permissions to be all read and write for everyone, I dumped my InDesign preferences. What else can I do? Has anyone had this problem before? (I am connected to the server now that I'm trying to reopen it.)
    When I started InDesign after it crashed, it asked me to recover the file and I tried to but it didn't open anything (I was not connected to the server at that point which may have screwed things up) There are two files in the InDesign Recovery folder one called 'RecoveryData' and one called 'DBTmp239689402256' both of which don't open in indesign.

    You may want to back up your work on a regular basis. Check out Retrospect or Retrospect Light. Lots of computers come with the light version so you may already have it.

  • On Adobe Acrobat Pro, how do I take a PDF file and convert it into an excel file?

    I am not sure how to take a PDF file and change it into an excel file. I have Adobe Acrobat Pro. Thanks!

    Using Acrobat XI Pro.
    File - Save As Other - Spreadsheet - Microsoft Excel Workbook
    Be well...

  • Read a excel file and split its sheets to seperate file ?

    Dear all :
    How to split a excel file into several file, each have one sheet.my code is as below,thanks:
    import org.apache.poi.hssf.usermodel.*;
    import java.io.*;
    import java.util.*;
    import org.apache.poi.poifs.filesystem.*;
    public class Extractxls {
    public static void main(String[] args) throws Exception
    try {
    POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(args[0]));
    HSSFWorkbook wb = new HSSFWorkbook(fs);
    int sheetCount = wb.getNumberOfSheets();
    System.out.println(sheetCount);
    try {
         while(sheetCount > 0) {
         sheetCount--;
         HSSFWorkbook wb1 = new HSSFWorkbook();
         HSSFSheet s = wb1.createSheet();
         String sheetName = wb.getSheetName(sheetCount);
         HSSFSheet sheet = wb.getSheet(sheetName);
    //     HSSFSheet sheet = wb.getSheetAt(sheetCount);
         System.out.println(sheet.toString());
         s = sheet;
    FileOutputStream fileOut = new FileOutputStream("atest" + sheetCount + ".xls");
    wb.write(fileOut);
    fileOut.close();
    } catch (Exception e) {
         System.err.println("Error: " + e.getMessage());
    } catch (Exception e) { e.toString();}

    The HSSFWorkbook class is part of the POI project:
    http://jakarta.apache.org/poi/
    Regards,
    Dave Gilbert
    JFreeChart Project Leader
    I understand poi porject, my problem is that POI can not read a excel file and split its sheets into seperate file (each have one sheet) ?Does any one know how to do it.

  • How can I change one section of the document to a landscape orientation and not the whole document?

    How can I change one section of the document to a landscape orientation and not the whole document?

    Page Setup, including page orientation, is done in the File menu. The setting applies to the whole document. As Peter says, you can rotate the contents of a page (not including the text layer of a word processing document).
    As an alternative, you could use Numbers, where Sheets are empty canvases onto which you may place images, charts, tables and text boxes, and where page orientation may be set for individual Sheets. The main tradeoff is that you lose many of the built-in word processing and page layout features of Pages.
    Regards,
    Barry

Maybe you are looking for

  • Wifi connection cuts out intermittently after updating to 6.1.3

    Since I updated to iOS 6.1.3, my iPad 2 is still connected to my wifi network, but it does not stay connected.  Every 4-6 seconds it will disconnect and then reconnect, often resulting in video playback stopping, gameplay interruption, and web page c

  • TS1717 Itunes crashes on Windows 7 64 bit

    Itunes is crashing when I try playback of a DVD.  I'm using Itunes 11.0.2.26 on Windows 7 64 bit.

  • WdsClient: An error occurred while obtaining an IP address from the DHCP server

    Trying to create and deploy a Windows 7 pro image for Dell optiplex 390s. Getting the dreaded error above when trying to connect to the DHCP. After a couple days of research I've tried injecting drivers, different version of drivers, injecting driver

  • New iPhone - when does service start?

    Just picked up a couple new iPhones - one for me, one for my wife. The guy at AT & T store said it would take a few hours before we were able to use the phones...well, it's been 5-1/2 hours now and no service. Is this normal??? JimO Erie, PA

  • Frustrated with Motion's instability

    I am pretty frustrated with Motion right about now. I understand it has some powerful capabilities (of which currently fulfill all my needs) and is in a relatively infantile state, however.... it is completely useless if it can't do what it should do