Problems deleting a string from an external file.

hi!
I am working on a program but am having problems deleting a string of information from an external file. The code I have managed to do only seems to be deleting the surname. The rest of the string remains and the Surname from the string bellow the one that should have been deleted moves to where the surname that was just deleated was.
this is the code snippet that should be deleting the string:
          System.out.print("Please enter the last name of the contact: ");
          last_name = dataInput.next();
          int z = 0;
          for (int i=0; i < number_of_records; i++)
                    if ((last_name.compareTo(lastName)) < i && (last_name.compareTo(lastName[i]) > i))
                              z = i;
          for (int i = z; i < number_of_records; i++)
                    lastName[i] = lastName[i+1];
Anyone got any ideas why its not deleting the whole string?
the extrenal file is set out like:
surname,,first name,,phone number

I don't think you have given enough information to answer this question completely; however, here is my guess:
The code that appears to be doing the "deleting"
for (int i = z; i < number_of_records; i++)
    lastName[i] = lastName[i+1];
}is only acting upon the lastName array.

Similar Messages

  • Need how to get the data from the external file in eCatt

    Hi ,
      Could any body suggest how to get the values from the external file(Excel,CSV file,Text file) and pass it as varaiable in ecatt Test script.
    Problem: Need to execute FK01-Vendor creation Transaction with multiple set of data .As per my understanding we could achive through Variants in Testdata set in eCatt .
    But is there any way to store the data in excell file and get the data and pass it to FK01 Test scripts
    Appreciate response on this

    Hi
    See the links they may be useful
    check these link,
    eCATT- An Introduction
    /people/sumeet.kaul/blog/2005/07/26/ecatt-an-introduction
    Creating Test Scripts
    /people/sumeet.kaul/blog/2005/08/10/ecatt-creating-test-scripts
    eCATT Logs
    /people/sapna.modi/blog/2006/04/18/ecatt-logs-part-vi
    eCATT Scripts Creation – TCD Mode
    /people/sapna.modi/blog/2006/04/10/ecatt-scripts-creation-150-tcd-mode-part-ii
    Creation of Test Data Container
    /people/sumeet.kaul/blog/2005/08/24/ecatt-creation-of-test-data-container
    eCATT Scripts Creation - SAPGUI Mode
    /people/sapna.modi/blog/2006/04/10/ecatt-scripts-creation--sapgui-mode-part-iii
    Integrating ECATT & MERCURY QTP Part -1
    /people/community.user/blog/2007/01/02/integrating-ecatt-mercury-qtp-part-1
    Using eCatt to Test Web Dynpro ABAP
    /people/thomas.jung/blog/2006/03/21/using-ecatt-to-test-web-dynpro-abap
    and
    -command reference
    http://help.sap.com/saphelp_nw04/helpdata/en/c6/3c333b40389c46e10000000a114084/content.htm
    /people/sapna.modi/blog/2006/04/10/ecatt--an-introduction-part-i
    http://prasadbabu.blogspot.com
    https://www.sdn.sap.com/sdn/developerareas/was.sdn?page=test_tool_integration_for_sap_e-catt.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/1b/e81c3b84e65e7be10000000a11402f/frameset.htm
    http://www.erpgenie.com/ecatt/index.htm
    hope this helps.
    Reward points for useful Answers
    Regards
    Anji

  • Syntax error while loading hierarchy from an external file

    Dear Expert:
    I am new to BW and I met a problem today while loading hierarchy from an external file. Actually I am following below article to load the hierarchy:
    /people/prakash.bagali/blog/2006/02/07/hierarchy-upload-from-flat-files
    When I schedule the infopackage, the error message says: "Syntax error in template RSTMPL9C, ROW 76". Actually there is only around 20 lines of records.
    Since I am not familiar with hierarchy load, so:
    1. while loading from external file, do I need to create one hierarchy in advance  through "Maintain Hierarchies" in the infoobject? My understanding is since I can load that hierarchy from file, so I do not need to create one in advance, once the load completed, the hierarchy should automatically generated there. Is my understanding correct?
    2. Before loading the hierarchy, do I need to load the master data of external characteristics in the hierarchy first? Here in my example, the sales hierarchy has 2 external characteritics (Country and region) in the hierarchy. Do I need to load some data first?
    3. My 'Preview' function in the infopackage is gray so that I can not test the data loading. Why is it gray?
    Information like file name, file dir, file type(csv), seperator should be correct there.
    Can anybody help me take a look into that? Many thanks for your time in advance!
    Tim

    Hi ctsiszidane:
    There are some other SAP Notes that can help you solve the problem.  Depending on your Support Package level check which of them is applicable.
    Note 659461 - RSAR 682: Syntax error in template RSTMPL9A, row 246
    Note 605690 - Escape characters are not processed correctly
    Note 620152 - Syntax error in RSTMPL9A during data loading from a file
    Regards,
    Francisco Milán.

  • Reading Each String From a text File

    Hello everyone...,
    I've a doubt in File...cos am not aware of File.....Could anyone
    plz tell me how do i read each String from a text file and store those Strings in each File...For example if a file contains "Java Tchnology forums, File handling in Java"...
    The output should be like this... Each file should contains each String....i.e..., Java-File1,Technology-File2...and so on....Plz anyone help me

    The Java� Tutorials > Essential Classes: Basic I/O

  • Indesign CS3-JS - Problem in reading text from a text file

    Can anyone help me...
    I have an problem with reading text from an txt file. By "readln" methot I can read only the first line of the text, is there any method to read the consecutive lines from the text file.
    Currently I am using Indesign CS3 with Java Script (for PC).
    My Java Script is as follows........
    var myNewLinksFile = myFindFile("/Links/NewLinks.txt")
    var myNewLinks = File(myNewLinksFile);
    var a = myNewLinks.open("r", undefined, undefined);
    myLine = myNewLinks.readln();
    alert(myLine);
    function myFindFile(myFilePath){
    var myScriptFile = myGetScriptPath();
    var myScriptFile = File(myScriptFile);
    var myScriptFolder = myScriptFile.path;
    myFilePath = myScriptFolder + myFilePath;
    if(File(myFilePath).exists == false){
    //Display a dialog.
    myFilePath = File.openDialog("Choose the file containing your find/change list");
    return myFilePath;
    function myGetScriptPath(){
    try{
    myFile = app.activeScript;
    catch(myError){
    myFile = myError.fileName;
    return myFile;
    Thanks,
    Bharath Raja G

    Hi Bharath Raja G,
    If you want to use readln, you'll have to iterate. I don't see a for loop in your example, so you're not iterating. To see how it works, take a closer look at FindChangeByList.jsx--you'll see that that script iterates to read the text file line by line (until it reaches the end of the file).
    Thanks,
    Ole

  • I have purchased adobe pdf pack so i can delete some text from my converted files, this will only let me add text but not delete any, please help

    i have purchased adobe pdf pack so i can delete some text from my converted files, this will only let me add text but not delete any, please help

    I tyhink that you need ExportPDF, Adobe ExportPDF (read only). In any case, thius may help: Cancel your membership or subscription | Acrobat.com online services

  • How can i delete a UserName  from a text file using Strings or io.

    hi i m trainee
    i have been assigned to make java program which deletes a UserName and
    his Passwor from a Text File
    i m unable to do it using the code below
    plz help
    do reply
      import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java .applet.*;
    import java.io.*;
    class Del extends JFrame  implements ActionListener
         String s2;
         JTextField CWDMUserDText = new JTextField();
         JButton CWDMSecDelButton = new JButton("DELETE");
         JLabel CWDMUserLabel = new JLabel("USER NAME");
         JPasswordField CWDMPassDText = new JPasswordField();
         JLabel CWDMPassLabel = new JLabel("PASSWORD");
         //String user,pass;
         /* CONSTRUCTOR*/
              Del()
                   Container contentPane=getContentPane();
                   contentPane.setLayout(null);
                  setLocation(400,200);
                   contentPane.add(CWDMUserDText);
                   contentPane.add(CWDMSecDelButton);
                   contentPane.add(CWDMUserLabel);
                   contentPane.add(CWDMPassDText);
                   contentPane.add(CWDMPassLabel);
                  CWDMUserLabel.setBounds(20,70,100,25);
                  CWDMPassLabel.setBounds(20,100,100,25);
                   CWDMUserDText.setBounds(150,70,100,25);
                   CWDMPassDText.setBounds(150,100,100,25);
                   CWDMSecDelButton.setBounds(80,135,100,25);
                   CWDMUserDText.addActionListener(this);
                   CWDMPassDText.addActionListener(this);
                   CWDMSecDelButton.addActionListener(this);
                   contentPane.setBackground(Color.CYAN);
                   setVisible(true);
                   setDefaultCloseOperation(EXIT_ON_CLOSE);
         public void actionPerformed(ActionEvent ae)
                  if(ae.getSource()==CWDMSecDelButton)
         //             user = CWDMUserDText.getText();
         //          pass = CWDMPassDText.getText();
         //          showarr();
                   s2 = CWDMUserDText.getText();
                   CWDMUserDText.setText("");
                   CWDMPassDText.setText("");
                   DelUser(s2);
              public static void main(String args[])
                   Del myframe1= new Del();
                   myframe1.setSize(300,200);
                   myframe1.setVisible(true);
              public void DelUser(String s)
                   //int a;
                   try
                        FileReader fr = new FileReader("file.txt");
                        BufferedReader br = new BufferedReader(fr);
                       String s1;
                       int a;
                       int len = s.length();
                       System.out.println(len);
                       //s2 = CWDMUserDText.getText();
                        while ((s1=br.readLine()) !=null)
                             if((a=s1.indexOf(s))>0 && (a=s1.indexOf(s))!=0)
                                  System.out.println(a);
                        fr.close();
                   catch(FileNotFoundException e)
                        System.out.println("exception occured");
                   catch(IOException e)
                        System.out.println("io");
         }

    Some tips:
    1) If you are adding or deleting stuff from a text file you need to write a new, modified file and then, optionally, do something like:
    rename the old file to whatever.bak or the like.
    rename the new file to the old.
    2) Don't depend on System.out so much on a GUI application. For example if you get an exception use javax.swing.JOptionPane to display an alert (and show the message from the exception). You can write the stack trace to System.out if you want.
    3) Don't muck about with calculating bounds for screen objects, let a layout manager sort it out. I like BoxLayoutManager for most things like this.
    4) For bonus points do your IO in a separate Thread. Generally you don't want anything happening in an actionPerformed method which significantly delays it's return. The method should launch a new Thread to do the job, and disable the button until the Thread finishes.

  • Help with deleting multiple strings from file.......

    I am trying to delete the same string that may appear multiple times in the file. Here is the output to the screen. Here is the code. I have been researching the delete method it says that I have to start at an index position in the string but how would I find out where the multiples strings reside in the file? I am getting the feeling that it won't work for my purpose..???? I am trying to delete all ot the strings "a string of data3" from the file.
    Output
    C:\TestRead>java StringDelete
    Temp String file_data-------- a string of data3a string of data2a string of data
    1a string of data3a string of data2a string of data1a string of data3
    Just A Blank Line
    Just A Blank Line
    Just A Blank Line
    String toDelete-------- a string of data3
    Just A Blank Line
    Just A Blank Line
    Just A Blank Line
    String toDelete-------- a string of data2
    Just A Blank Line
    Just A Blank Line
    Just A Blank Line
    String toDelete-------- a string of data1
    Just A Blank Line
    Just A Blank Line
    Just A Blank Line
    String toDelete-------- a string of data3
    Just A Blank Line
    Just A Blank Line
    Just A Blank Line
    String toDelete-------- a string of data2
    Just A Blank Line
    Just A Blank Line
    Just A Blank Line
    String toDelete-------- a string of data1
    Just A Blank Line
    Just A Blank Line
    Just A Blank Line
    String toDelete-------- a string of data3
    Just A Blank Line
    Just A Blank Line
    Just A Blank Line
    Code:
    import java.io.*;
    public class StringDelete
    public static void main(String [] args)
    try
    FileInputStream fis = new FileInputStream("TestFile.txt");
    DataInputStream in = new DataInputStream(fis);
    StringBuffer file_data = new StringBuffer();
    while(in.available() > 0)
    String temp = in.readUTF(); // read in a string from the file
    file_data.append(temp); // append it to the buffer
    System.out.println("Temp String file_data-------- " + file_data);
    System.out.println("Just A Blank Line");
    System.out.println("Just A Blank Line");
    System.out.println("Just A Blank Line");
    boolean keepGoing = true;
    while(keepGoing)
    String toDelete = file_data.substring(0, "a string of data3".length());
    System.out.println("String toDelete-------- " + toDelete);
    System.out.println("Just A Blank Line");
    System.out.println("Just A Blank Line");
    System.out.println("Just A Blank Line");
    if(toDelete == null || toDelete.equals("") )
    keepGoing = false;
    else
    file_data.delete(0,"a string of data3".length());
    catch(IOException e)
    e.printStackTrace();

    Here is the output. I am trying to get each part to work before I go on to the next part that is why some code is commented out.
    I need help to know why string "a string of data3" is not deleted in the towrite string??
    Output:
    C:\TestRead>java NewStringDelete
    String v after remove [ &#9668;a string of data3 &#9668;a string of data2 &#9668;a string of data1
    &#9668;a string of data3 &#9668;a string of data2 &#9668;a string of data1 &#9668;a string of data3]
    String towrite after remove &#9668;a string of data3 &#9668;a string of data2 &#9668;a string of
    data1 &#9668;a string of data3 &#9668;a string of data2 &#9668;a string of data1 &#9668;a string of data
    3
    Code:
    import java.util.Vector;
    import java.io.*;
    public class NewStringDelete
         public static void main(String [] args)
              //String ls = System.getProperty("line.separator");
              //File file;
              Vector v=new Vector();
         try{
              BufferedReader br=new BufferedReader(new FileReader ("TestFile.txt"));
              String s;
              while ((s=br.readLine())!=null)
                   {v.addElement(new String(""+s));}
                        br.close();
         catch(IOException e)
                   e.printStackTrace();
    /*now you have a Vector containing String objects..*/
         String remove = ("a string of data3");
         String towrite="";
    System.out.println("String v after remove " + v);     
         for (int i=0; i<v.size();i++)
              String ss = (String)v.elementAt(i);
              if (ss.equalsIgnoreCase(remove)){continue;}
              //     towrite=towrite+ss+ls;
                   towrite=towrite+ss;
    System.out.println("");               
    System.out.println("");               
    System.out.println("String towrite after remove " + towrite);                    
    /*do filewrite*/
    //try{
    // FileWriter fw=new FileWriter(TestFile.txt);
    // fw.write(towrite);
    // fw.close();
    // catch(IOException e)
    //               e.printStackTrace();

  • Problem with reading String from Xlsx file.

    Hi! I am trying to read string and numerical data from an xlsx file and trying to display its contents in a word file. I tried converting it to a .lvm file too. On using the "Read From Spreadsheet" tool, I get random characters as output. On using " Read From Measurement File" tool, I am getting an error saying "Error 100 occurred at Read From Measurement File->Untitled 1". What do I do? At the end I need to display the output, row by row, in a Microsoft Word file. I am so lost. Please Help.
    Solved!
    Go to Solution.

    bsvare wrote:
    labview currently does not read directly from an xlsx file. If you convert the xlsx to an xls file first, then you can use the read from spreadsheet tool to load the data from the file.
    Hey, I tried doing that. It still just gave the values 0.00 in all the cells of the indicator array. Plus my file has string in it also. The data type in the spreadsheet was "general". Here in the tool, it is "Double". I changed the tool data type to string and spreadsheet to text but I only got gibbrish for my efforts.
    Thanks anyway!

  • Flash CC Air iOS: Problems with loading text from an external xml located on a server.

    So I have this code allowing me to load text from an xml located on a server. Everything works fine on the Air for Android. The app even works in the ios emulator, but once I export my app to my ios device with ios 7, I don't see any text. The app is developed with Air sdk 3.9. What could be the reason? Do I need any special permissions like on Android? Does ios even allow to load xml from an external server?
    Any clues?

    It was my bad. I linked to a php file to avoid any connection lags, which was absolutely fine on the android, but didn't seem to work on the ios 7. So all I did is change the php extension to xml and it worked without any problems.

  • Deleting a line from a text file & opening a project from another project

    hi
    im doing project on linux redhat 8.0 using java (jbuilder 8). I need to
    open a project2 from behind a menu item in project1. I tried importing
    the package of project2 and then initializing a constructor of main
    class of project2 in project1(behind the "open project2" menu item) but
    i dont know where to place the class files of project2 so im getting a
    compilation error(when compiling project1) that unable to locate
    imported package files.
    is there any other way of doing this
    like making an .exe file of project2??? if so, then pls tell me how.
    Another problem is i want to delete a line of selected text from a text
    file
    using java. is there a method for that or any other way?
    Anybodyyyy have any ideasss?
    Alisha

    Cross- and double-posted: http://forum.java.sun.com/thread.jspa?threadID=645244

  • I have a problem to  extract data from oracle dump file (.dmp) using oracle database or any other tools.

    There is IMP utility which provides me data as graphical way. But i need extract data in such a way so that i could able to use in my application.
    thanks,
    mohan

    Hi,
    EdStevens
    Actually I was using SQL Developer. Sorry for the wrong define question. Now the real problem is:
    I want to read or extract data in a txt file from Oracle Dump (.dmp) file without using Oracle sqlPlus or Oracle Database.
    No need to say that i am able to extract dump data using sqlPlus. But for that, there is a little burden to install oracle database
    or sql Developer.
    I also listen about Oracle Loader a little bit. Is it a tool for providing extraction of data from Oracle dump file.
    Thanks for your previous reply,
    And now waiting for your suggestion.
    thanks,
    mohan

  • Problem delete chang log from process chain BW 7.01

    We have upgrade BW from 3.5 version to 7.01 version two month ago.
    Now I realized that the process chain running one a week to delete PSA and change log don't work well after upgrade.
    The process chain end without errors (status is green), but the change log are not deleted.
    In the test system I try to delete the Change Log in 2 mode:
    1-with the variant "Deletion of Requests from the Change Log " and the datastoreobject = myods and all the option (correct request, incorrect request and "Delete Activation Requests Only"). In the log i see this messagge
    The following excluded selections will be processed:
    No excluded selections found
    The following included selectiosn will be processed:
    Pattern: DataStore = 0FIGL_O06, InfoArea = *
    The following reqeust selections were set:
    Number of days = 0000000010, Successful = X, Incorrect = X, Curr. Requests =
    The following change logs were selected:
    2-with the variant "Deletion of Requests from PSA " and the datasource= 8myods and all the option (correct request, incorrect request).  In the log i see this messagge
    The following excluded selections will be processed:
    No excluded selections found
    The following included selectiosn will be processed:
    Pattern: DS = 80FIGL_O06, LS = BWTCLNT100, IS = , AC =
    The following reqeust selections were set:
    Number of days = 0000000015, Successful = X, Incorrect = X, Load requests =
    The following PSAs were selected:
    In both case the change log is not deleted.
    I can delete the change log only using Manage screen of my ods and then using Menu -> Environment ->Delete Change Log Data.
    Anna Maria

    I see that this topic is still active/unanswered...
    We're having the same problem, but not just changelogs, also for PSAs. We have a weekly process chain that does housekeeping on our BW system, cleaning up PSAs and changelogs, compressing cubes, realigning time-dep masterdata and renewing indexes.
    The PSA chain runs fine and about 90% of all PSAs get deleted, but there are some datasources (all of them are of type 8* datamart datasources) that don't get their PSAs deleted. It says "The following PSAs were selected:" and then nothing happens...
    I tried all tickbox combinations and checked that there are no PSA entries blocked by invalid partitions. Manual deletion (via "manage" in the datasource) works fine, but is tedious and time consuming.
    Also, most of the 8* datasource PSAs do get deleted. Just a handful (+/- 25) get skipped somehow.
    Any ideas?
    Thanks,
    Eduard
    PS: We're still running 3.5-style backend dataflow, but will eventually get converted to transformations and DTPs. But that's not on our agenda (yet).

  • Problem while retreiving data from a text file

    AOA
    I tried to retreive text from a .txt file.
    By using following code, i get junk box after every character retreived. What may be the reason.
    public void run()
    try
    FileReader reader = new FileReader(uidsFile);
    BufferedReader bin = new BufferedReader(reader);
    while((line = bin.readLine()) != null )
    String uid =line;// line.substring(0,4);
    System.out.println(uid.trim());
    catch(Exception x)
    JOptionPane.showMessageDialog(null ,
    x.getStackTrace(),
    JOptionPane.INFORMATION_MESSAGE);
    }

    The reason would be that that is what your text file looks like (namely UTF-16) while you use a FileReader without specifying any encoding, which means that it will choose your platform default - which is not UTF-16.

  • I can't delete my backups from my external harddisk, what do I do?

    I have tried to delete some om the backups from my external harddisk, but it only through them into the trash. When I then try to empty my trash nothing happens, it just stays there. If I then try to remove my harddisk it's gone, but when I put it back in I appears again...

    In Mail, go to Mailbox (menu item) and in the drop down go to Erase Deleted Items, then select in All Accounts.l

Maybe you are looking for

  • Update material doc.num in assignment field of GR/IR line item of a/c doc

    HI Experts, please tell me the solution for my problem My requirement : Transaction is : MIGO Before posting of material document, update material document number in assignment field of GR/IR line item of accounting document (WE) at number commitment

  • Posting Stock In plant

    While doing stock posting(MB1C) in plant I am Getting the following Error. 1). Posting only possible in periods 2008/03 and 2008/02 in company code ENSU 2). IN MB1C DOCUMENT DATE = 10.01.2008 3). IF  I AM GIVING 10.03.2008(BASED ON THAT ERROR) IT THR

  • Show all History is no longer showing since recent update

    After a recent Firefox update my History disappeared when doing "Show all History". Have checked preferences. Settings seemed to have not changed. How do I fix?

  • How to turn waste into a sundry stock item in SAP B1

    G'day folks, This is my first post ot the SAP B1 forum, and probably wont be the last. So far I've used this forum to resolve most problems, but I have an issue with I havn't seen to date on any thread. Two of the 6 companies I'm implementing in SAP

  • Random Text that I can't get rid of

    A text caption is appearing on slides where I did not place it on the stage. It is not appearing in the timeline. I can not select it. It is not on the master slide. I do not understand where it came from or how to get rid of it. Can anyone help me?