Results 1 to 2 of 2
Like Tree1Likes
  • 1 Post By jim829

Thread: Removing quotes:

  1. #1
    jocdrew21 is offline Senior Member
    Join Date
    Jan 2014
    Rep Power

    Default Removing quotes:

    I found this program idea online. It has 5000 names written as "SOMENAME","SOMEOTHERNAME","ETC" and I have to spilt them up and do a few other things. Well I spilt them up but I cannot get rid of the quotes. I like to do it before I pass it into the ArrayList so that I can tackle the next step of the program. Any ideas?

    Java Code:
    import java.util.ArrayList;
    public class SplitList
    	ArrayList<String> myList = new ArrayList<String>();
    	String array[];
    	private String line = "";
    	int counter = 0;
    	void readFile() throws Exception
    		FileReader inFile = new FileReader("names.txt");
    		BufferedReader buffer = new BufferedReader(inFile);
    		while((line = buffer.readLine()) != null)
    			array = line.split(",");
    			for(int i=0; i<array.length;i++)
    	void printFile()
    		for(int i=0; i<myList.size();i++)
    	public static void main(String[] args) 
    		SplitList s = new SplitList();
    		}catch(Exception ex)
    			System.out.println("Unable to open or find file");

  2. #2
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Northern Virginia, United States
    Rep Power

    Default Re: Removing quotes:

    There are a variety of approaches. I prefer regular expressions. But you could just split them based on their commas (,) and then simply use the String functions to search for the quotations marks and simply delete them. Check out java.util.regex and java.lang.String.

    jocdrew21 likes this.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. checking for quotes in a string
    By kilyx in forum New To Java
    Replies: 3
    Last Post: 12-15-2011, 01:06 AM
  2. Quotes around variables
    By jadroe in forum New To Java
    Replies: 3
    Last Post: 03-16-2011, 10:49 PM
  3. unbalanced quotes in -
    By fresh83 in forum New To Java
    Replies: 2
    Last Post: 12-19-2009, 02:10 AM
  4. Stock Quotes
    By BartDR in forum Advanced Java
    Replies: 0
    Last Post: 09-15-2009, 10:15 AM
  5. The Fav. Programming Quotes Thread
    By angryboy in forum Forum Lobby
    Replies: 3
    Last Post: 06-13-2009, 11:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts