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