List of usage examples for java.lang String equalsIgnoreCase
public boolean equalsIgnoreCase(String anotherString)
From source file:MainClass.java
public static void main(String[] args) { int number = 2; String input = "Y"; while (input.equalsIgnoreCase("Y")) { System.out.println(number + " "); System.out.print("Do you want to keep counting?" + " (Y or N)"); input = sc.next();// w w w.ja v a 2s. c o m number += 2; } }
From source file:MainClass.java
public static void main(String[] arg) { String a = "a"; String b = "A"; if (a.equalsIgnoreCase(b)) { System.out.println("a==b"); } else {/*from ww w. j a v a 2s . c o m*/ System.out.println("a!=b"); } }
From source file:Main.java
public static void main(String args[]) { String s1 = "java2s.com"; String s2 = "Java2s.com"; System.out.println(s1.equalsIgnoreCase(s2)); }
From source file:Main.java
public static void main(String[] args) { String str1 = "Hello"; String str2 = "HELLO"; if (str1.equalsIgnoreCase(str2)) { System.out.println("Ignoring case str1 and str2 are equal"); } else {/*w w w. j a v a 2 s . com*/ System.out.println("Ignoring case str1 and str2 are not equal"); } if (str1.equals(str2)) { System.out.println("str1 and str2 are equal"); } else { System.out.println("str1 and str2 are not equal"); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { ImageInputStream imageStream = ImageIO.createImageInputStream(new URL("").openStream()); Iterator<ImageReader> readers = ImageIO.getImageReaders(imageStream); ImageReader reader = null;/* w w w.ja v a 2s . c o m*/ if (!readers.hasNext()) { imageStream.close(); return; } else { reader = readers.next(); } String formatName = reader.getFormatName(); if (!formatName.equalsIgnoreCase("jpeg") && !formatName.equalsIgnoreCase("png") && !formatName.equalsIgnoreCase("gif")) { imageStream.close(); return; } reader.setInput(imageStream, true, true); BufferedImage theImage = reader.read(0); reader.dispose(); imageStream.close(); }
From source file:ReadZip.java
public static void main(String args[]) { try {/*ww w . j a v a2 s . c o m*/ ZipFile zf = new ZipFile("ReadZip.zip"); Enumeration entries = zf.entries(); BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); while (entries.hasMoreElements()) { ZipEntry ze = (ZipEntry) entries.nextElement(); System.out.println("Read " + ze.getName() + "?"); String inputLine = input.readLine(); if (inputLine.equalsIgnoreCase("yes")) { long size = ze.getSize(); if (size > 0) { System.out.println("Length is " + size); BufferedReader br = new BufferedReader(new InputStreamReader(zf.getInputStream(ze))); String line; while ((line = br.readLine()) != null) { System.out.println(line); } br.close(); } } } } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) throws Exception { File CFile = new File("data.xml"); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setIgnoringComments(true);/*from ww w . ja va 2 s . co m*/ factory.setIgnoringElementContentWhitespace(true); factory.setValidating(false); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse(CFile); NodeList pizzas = document.getElementsByTagName("Pizza"); for (int i = 0; i < pizzas.getLength(); i++) { Element pizzaSize = (Element) pizzas.item(i); String pSize = pizzaSize.getAttribute("Size"); if (pSize.equalsIgnoreCase("Large")) System.out.println(10.0); if (pSize.equalsIgnoreCase("Medium")) System.out.println(7.0); if (pSize.equalsIgnoreCase("Small")) System.out.println(5.0); } }
From source file:Main.java
public static void main(String[] args) throws Exception { DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document doc = db.parse(new InputSource( new StringReader("<emp><empname><firstName></firstName><lastName></lastName></empname></emp>"))); NodeList customerNodes = doc.getElementsByTagName("empname"); for (int i = 0; i < customerNodes.getLength(); i++) { NodeList children = customerNodes.item(i).getChildNodes(); for (int j = 0; j < children.getLength(); j++) { String childNode = children.item(j).getNodeName(); if (childNode.equalsIgnoreCase("firstName")) { children.item(j).setTextContent(String.valueOf("John")); } else if (childNode.equalsIgnoreCase("lastName")) { children.item(j).setTextContent(String.valueOf("Doe")); }// w w w.j a va 2 s. co m } } TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); StringWriter writer = new StringWriter(); transformer.transform(new DOMSource(doc), new StreamResult(writer)); System.out.println(writer.getBuffer().toString()); }
From source file:bixo.tools.RunUrlNormalizerTool.java
/** * @param args// ww w. j av a2 s . c om */ public static void main(String[] args) { String curUrl = null; try { List<String> lines = FileUtils.readLines(new File(args[0])); BaseUrlNormalizer urlNormalizer = new SimpleUrlNormalizer(); for (String url : lines) { curUrl = url; String normalized = urlNormalizer.normalize(curUrl); if (!normalized.equalsIgnoreCase(curUrl)) { System.out.println(curUrl + " ==> " + normalized); } } } catch (Throwable t) { System.err.println("Exception while processing URLs: " + t.getMessage()); System.err.println("Current url: " + curUrl); t.printStackTrace(System.err); System.exit(-1); } }
From source file:MainClass.java
public static void main(String args[]) { try {//from w ww. j a v a 2s. com SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser saxParser = factory.newSAXParser(); DefaultHandler handler = new DefaultHandler() { boolean name = false; public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if (qName.equalsIgnoreCase("NAME")) { name = true; } } public void characters(char ch[], int start, int length) throws SAXException { if (name) { System.out.println("Name: " + new String(ch, start, length)); name = false; } } }; saxParser.parse(new InputSource(new StringReader(xmlString)), handler); } catch (Exception e) { e.printStackTrace(); } }