Java error notepad-record errors in cainiao programming.

Source: Internet
Author: User

1: When dataoutputstream java. Lang. nullpointerexception uses dataoutputstream to read and write data, the nullpointerexception error occurs because the dataoutputstream is not initialized.

Two pairs of files use bufferedreader and bufferedwrite at the same time. If you read data after blood donation, the buffer may not be refreshed when you cannot read the data. Therefore, you must refresh the buffer before reading the data: flush

Import Java. io. bufferedreader; import Java. io. bufferedwriter; import Java. io. fileinputstream; import Java. io. filenotfoundexception; import Java. io. filereader; import Java. io. filewriter; import Java. io. ioexception; public class bufferedreaderandbufferedwiter {public static void main (string [] ARGs) {// todo auto-generated method stubtry {filereader Fr = new filereader ("F: \ out.txt "); bufferedreader BR = new bufferedreader (FR); filewriter fw = new filewriter (" F: \ out.txt "); bufferedwriter BW = new bufferedwriter (FW ); string STR = NULL; For (INT I = 0; I <100; I ++) {STR = string. valueof (math. random (); BW. write (STR); BW. newline (); // system. out. println (STR);} BW. flush (); //Here While (STR = Br. Readline ())! = NULL) {// system. Out. println ("test! "); System. out. println (STR);} BW. close (); BR. close ();} catch (filenotfoundexception e) {// todo auto-generated catch blocke. printstacktrace ();} catch (ioexception e) {system. out. println ("This Is A ioexception! ");}}}  

2. Regular Expression:

(Or) There are two meanings in the regular expression. First, the literal meaning is used to match (OR), and then he needs to be escaped in Java, 2. It is used to include a regular expression (-| // s) without escaping.

3. When deploying JavaBean on the server:Cannot be resolved to a Type Error

Cause: the self-built class (that is, the bean to be generated) is placed in the default package.

Solution: Customize a package

4 when using newinstance () to create a class, it must contain the default constructor, else java. Lang. nullpointerexception

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.