List of usage examples for java.lang System err
PrintStream err
To view the source code for java.lang System err.
Click Source Link
From source file:UDPReceive.java
public static void main(String args[]) { try {//from www.ja va 2 s. c om int port = 90; // Create a socket to listen on the port. DatagramSocket dsocket = new DatagramSocket(port); // Create a buffer to read datagrams into. If a // packet is larger than this buffer, the // excess will simply be discarded! byte[] buffer = new byte[2048]; // Create a packet to receive data into the buffer DatagramPacket packet = new DatagramPacket(buffer, buffer.length); // Now loop forever, waiting to receive packets and printing them. while (true) { // Wait to receive a datagram dsocket.receive(packet); // Convert the contents to a string, and display them String msg = new String(buffer, 0, packet.getLength()); System.out.println(packet.getAddress().getHostName() + ": " + msg); // Reset the length of the packet before reusing it. packet.setLength(buffer.length); } } catch (Exception e) { System.err.println(e); } }
From source file:BeanUtilsExampleV4.java
public static void main(String args[]) throws Exception { BeanUtilsExampleV4 diff = new BeanUtilsExampleV4(); Actor actor = diff.prepareData();// w ww. j ava2s . c o m ConvertUtilsBean convertUtilsBean = new ConvertUtilsBean(); convertUtilsBean.deregister(String.class); convertUtilsBean.register(new MyStringConverter(), String.class); convertUtilsBean.deregister(Long.class); convertUtilsBean.register(new MyLongConverter(), Long.class); convertUtilsBean.register(new MyLongConverter(), Long.TYPE); BeanUtilsBean beanUtilsBean = new BeanUtilsBean(convertUtilsBean, new PropertyUtilsBean()); System.err.println("==== Values before calling describe ==== "); System.err.println("By PropertyUtils: " + PropertyUtils.getProperty(actor, "name")); System.err.println("By BeanUtils: " + beanUtilsBean.getProperty(actor, "name")); System.err.println(beanUtilsBean.getProperty(actor, "worth")); Map describedData = beanUtilsBean.describe(actor); // check the map System.err.println("==== Values in Map ==== "); System.err.println(describedData.get("name")); System.err.println(describedData.get("worth")); // create a new Actor Bean Actor newActor = new Actor(); beanUtilsBean.populate(newActor, describedData); System.err.println("==== Values after calling populate ==== "); System.err.println(beanUtilsBean.getProperty(newActor, "name")); System.err.println(beanUtilsBean.getProperty(newActor, "worth")); }
From source file:LabelSampleSaveText.java
public static void main(String args[]) { JFrame frame = new JFrame("Label Focus Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(new BorderLayout()); JLabel label = new JLabel("Name: "); label.setDisplayedMnemonic(KeyEvent.VK_N); JTextField textField = new JTextField(); label.setLabelFor(textField);// w w w. j a va 2s. c o m panel.add(label, BorderLayout.WEST); panel.add(textField, BorderLayout.CENTER); frame.add(panel, BorderLayout.NORTH); frame.add(new JButton("Somewhere Else"), BorderLayout.SOUTH); frame.setSize(250, 150); frame.setVisible(true); textField.setText("your text"); String filename = "test.txt"; FileWriter writer = null; try { writer = new FileWriter(filename); textField.write(writer); } catch (IOException exception) { System.err.println("Save oops"); } finally { if (writer != null) { try { writer.close(); } catch (IOException exception) { System.err.println("Error closing writer"); exception.printStackTrace(); } } } }
From source file:com.bitsofproof.supernode.main.Main.java
public static void main(String[] args) throws Exception { log.info("bitsofproof supernode (c) 2013 bits of proof zrt."); log.trace("Spring context setup"); if (args.length == 0) { System.err.println( "Usage: java com.bitsofproof.main.Main profile [profile...] -- [args...] [options...]"); return;//from w w w.ja v a 2 s . co m } GenericXmlApplicationContext ctx = new GenericXmlApplicationContext(); List<String> a = new ArrayList<String>(); boolean profiles = true; for (String s : args) { if (s.equals("--")) { profiles = false; } else { if (profiles) { log.info("Loading profile: " + s); ctx.getEnvironment().addActiveProfile(s); } else { a.add(s); } } } ctx.load("classpath:context/server.xml"); ctx.load("classpath:context/*-profile.xml"); ctx.refresh(); ctx.getBean(App.class).start(a.toArray(new String[0])); }
From source file:br.com.great.resource.Executa.java
/** * * @param args String//from ww w . ja va 2 s. c om */ public static void main(String[] args) { Texto t = new Texto(); t.setMecsimples_id(1); t.setTexto("aaaaaaaa"); t.setCapturarObjeto(new CapturarObjeto()); t.getCapturarObjeto().setTipo(99); t.getCapturarObjeto().setNome("carleandro"); PlayJogo.getMecTextos().add(t); Missao m = new Missao(); m.setMecanica(new ArrayList<Mecanica>()); m.getMecanica().add(t.getCapturarObjeto()); PlayJogo.getMissoes().add(m); System.err.println(PlayJogo.getMissoes().get(0).getMecanica().get(0).getNome()); System.err.println(PlayJogo.getMecTextos().get(0).getCapturarObjeto().getNome()); PlayJogo.getMecTextos().get(0).getCapturarObjeto().setNome("olivia"); System.err.println(PlayJogo.getMissoes().get(0).getMecanica().get(0).getNome()); System.err.println(PlayJogo.getMecTextos().get(0).getCapturarObjeto().getNome()); }
From source file:OutlineActionsHyperLinkPDF.java
public static void main(String[] args) { Document document = new Document(); try {/* ww w .j a v a 2 s . c o m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("OutlineActionsHyperLinkPDF.pdf")); writer.setViewerPreferences(PdfWriter.PageModeUseOutlines); document.open(); document.add(new Paragraph("Outline action example")); PdfContentByte cb = writer.getDirectContent(); PdfOutline root = cb.getRootOutline(); PdfOutline links = new PdfOutline(root, new PdfAction("http://www.java2s.com"), "Useful links"); links.setColor(new Color(0xFF, 0x00, 0x00)); links.setStyle(Font.BOLD); } catch (Exception ioe) { System.err.println(ioe.getMessage()); } document.close(); }
From source file:nl.knaw.dans.easy.sword2examples.ContinuedDeposit.java
public static void main(String[] args) throws Exception { if (args.length != 5) { System.err.println( "Usage: java nl.knaw.dans.easy.sword2examples.ContinuedDeposit <Col-IRI> <EASY uid> <EASY passwd> <chunk size> <bag dirname>"); System.exit(1);/*from w w w .j ava2s . c om*/ } // 0. Read command line arguments final IRI colIri = new IRI(args[0]); final String uid = args[1]; final String pw = args[2]; final int chunkSize = Integer.parseInt(args[3]); final String bagFileName = args[4]; depositPackage(new File(bagFileName), colIri, uid, pw, chunkSize); }
From source file:dualcontrol.CryptoClientDemo.java
public static void main(String[] args) throws Exception { if (args.length != 3) { System.err.println("CryptoClientDemo usage: hostAddress port text"); } else {//from ww w .j a v a 2s .c o m new CryptoClientDemo().call(System.getProperties(), new MockableConsoleAdapter(System.console()), args[0], Integer.parseInt(args[1]), args[2].getBytes()); } }
From source file:AddingNewLinePDF.java
public static void main(String[] args) { Document document = new Document(); try {/*from w ww . j av a 2 s . c om*/ PdfWriter pdf = PdfWriter.getInstance(document, new FileOutputStream("AddingNewLinePDF.pdf")); RtfWriter2 rtf = RtfWriter2.getInstance(document, new FileOutputStream("AddingNewLine.rtf")); HtmlWriter html = HtmlWriter.getInstance(document, new FileOutputStream("AddingNewLine.html")); document.open(); document.add(new Paragraph("Some text")); Anchor pdfRef = new Anchor("http://www.java2s.com"); pdfRef.setReference("http://www.java2s.com"); Anchor rtfRef = new Anchor("Link for aFile.rtf."); rtfRef.setReference("./aFile.rtf"); document.add(pdfRef); document.add(Chunk.NEWLINE); document.add(rtfRef); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:DOMDump.java
static public void main(String[] arg) { boolean validate = true; DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(validate);/* w w w.ja v a 2 s . co m*/ dbf.setNamespaceAware(true); dbf.setIgnoringElementContentWhitespace(true); // Parse the input to produce a parse tree with its root // in the form of a Document object Document doc = null; try { DocumentBuilder builder = dbf.newDocumentBuilder(); builder.setErrorHandler(new MyErrorHandler()); InputSource is = new InputSource("personWithDTD.xml"); doc = builder.parse(is); } catch (SAXException e) { System.exit(1); } catch (ParserConfigurationException e) { System.err.println(e); System.exit(1); } catch (IOException e) { System.err.println(e); System.exit(1); } dump(doc); }