public List<Cookie> read(Reader rdr, String fileName) throws IOException { List<Cookie> ret = new ArrayList<Cookie>();  BufferedReader is = new BufferedReader(rdr);  if (!is.readLine().startsWith(MAGIC)) die(fileName + " not a cookies file"); String line; while ((line = is.readLine()) != null) { if (line.startsWith(COMMENT)) continue; if (line.length() == 0) continue; StringTokenizer st = new StringTokenizer(line, "\t"); int count = -1; if (st.countTokens() == Cookie.WIDTH) { count = Cookie.WIDTH; } else if (st.countTokens() == Cookie.WIDTH-1) { count = Cookie.WIDTH-1; } else { System.err.println("BAD INPUT: Line " + line + " has " + st.countTokens() + " tokens!"); continue; }   String domain = (String)st.nextToken(); boolean clientSide = st.nextToken().equals("TRUE")?true:false;   String path; if (count < Cookie.WIDTH) path = "/"; else path = (String)st.nextToken(); boolean secure = st.nextToken().equals("TRUE")?true:false; int expiry = Integer.parseInt(st.nextToken()); String name = (String)st.nextToken(); String value = (String)st.nextToken();  Cookie c = new Cookie( name, value, domain, path, expiry, secure, clientSide);  ret.add(c); }  return ret;
public List<Cookie> read(String fileName) throws FileNotFoundException, IOException { Reader is = new FileReader(fileName);  return read(is, fileName);
	public List<Cookie> read(Reader rdr, String fileName) throws IOException {		List<Cookie> ret = new ArrayList<Cookie>();		BufferedReader is = new BufferedReader(rdr);		if (!is.readLine().startsWith(MAGIC))			die(fileName + " not a cookies file");		String line;		while ((line = is.readLine()) != null) {			if (line.startsWith(COMMENT))				continue;			if (line.length() == 0)				continue;			StringTokenizer st = new StringTokenizer(line, "\t");			int count = -1;			if (st.countTokens() == Cookie.WIDTH) {				count = Cookie.WIDTH;			} else if (st.countTokens() == Cookie.WIDTH-1) {				count = Cookie.WIDTH-1;			} else {				System.err.println("BAD INPUT: Line " + line + " has " + st.countTokens() + " tokens!");				continue;			}			// The order that Netscape uses in this file is a wonder to behold.			String domain = (String)st.nextToken();			boolean clientSide = st.nextToken().equals("TRUE")?true:false;			// Some slimeball sites use "" as the path. Correct on the fly.			String path;			if (count < Cookie.WIDTH)				path = "/";			else				path = (String)st.nextToken();			boolean secure = st.nextToken().equals("TRUE")?true:false;			int expiry = Integer.parseInt(st.nextToken());			String name = (String)st.nextToken();			String value = (String)st.nextToken();			Cookie c = new Cookie(				name, value,				domain, path,				expiry,				secure, clientSide);			ret.add(c);		}		return ret;	}