learning java FileWriter】的更多相关文章

import java.io.FileWriter; import java.io.IOException; public class FileWriterTest { public static void main(String[] args) { try { var fw = new FileWriter("pop.txt"); { fw.write("11111\r\n"); fw.write("11111\r\n"); fw.write(…
Chapter 2 Learning Java language fundamentals exercises: 1.What  is Unicode? Unicode is a computing industry standard for consistently encoding,representing,and handling text that's expressed in most of world's writing system 2.What is a comment? A c…
import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class FWFRDemo { final static String MSG = "Test message"; public static void main(String[] args) throws IOException { try (FileWriter fw = new FileWriter(&…
曹海成的专栏 http://blog.csdn.net/caohaicheng/article/details/38071097 http://blog.csdn.net/a5489888/article/details/8278301 http://blog.csdn.net/fmh2011/article/details/39205759 http://blog.csdn.net/caohaicheng/article/details/38116481 java nio http://blo…
I/O Streams, it simplifies I/O operations, write a whole object out to stream & read back. File I/O and file system operations, including random access files. Classes about I/O Streams most are in java.io, about File I/O are in java.nio.file. I/O Str…
Java is using Unicode set Java is case sensitive Comments, C/C++ style abstract, const, final, int, public, throw, assert, continue, finally, interface, return, throws, boolean, default, float, long, short, transient, break, do, for, native, static,…
Java characteristics: Java .class files are machine-independent, including the endianness. Java .class files are not optimized .class files comprises "bytecode" different from "interpreted languages" in an additional step javac (source…
这个课程的参考视频在youtube. 主要学到的知识点有: set up needs Java SE JDK, NetBeans IDE class name should be the same like .java file name. .java is java file, .jar is compiled code. "clean and build" did clean old .jar file and create a new .jar file. For keyboar…
import java.io.IOException; import java.nio.file.*; public class WatchServiceTest { public static void main(String[] args) throws IOException, InterruptedException { WatchService watchService = FileSystems.getDefault().newWatchService(); Paths.get("C…
import java.io.IOException; import java.nio.file.*; import java.nio.file.attribute.BasicFileAttributes; public class FileVisitorTest { public static void main(String[] args) throws Exception { // 遍历g:\publish\codes\15目录下的所有文件和子目录 Files.walkFileTree(P…
import java.nio.file.Path; import java.nio.file.Paths; public class PathTest { public static void main(String[] args) throws Exception { Path path = Paths.get("."); System.out.println("path里包含的路径数目" + path.getNameCount()); System.out.p…
import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.nio.channels.FileLock; public class FileLockTest { public static void main(String[] args) { try ( var channel = new FileOutputStream("a.txt…
import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.CharacterCodingException; import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetEncoder; public class CharsetTransform {…
import java.nio.charset.Charset; import java.util.SortedMap; public class CharsetTest { public static void main(String[] args) { SortedMap<String, Charset> map = Charset.availableCharsets(); for (var alias : map.keySet()){ System.out.println(alias +…
import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; public class RandomFileChannelTest { public static void main(Str…
import java.nio.CharBuffer; public class BufferTest { public static void main(String[] args) { CharBuffer buff = CharBuffer.allocate(); System.out.println("capacity: " + buff.capacity()); System.out.println("limit: " + buff.limit());;…
public class Person implements java.io.Serializable { private String name; private transient int age; // 注意此处没有提供无参数的构造器! public Person(String name, int age) { System.out.println("有参数的构造器"); this.name = name; this.age = age; } // 省略name与age的sett…
对Person类实例进行序例化及反序例化: Person.java public class Person implements java.io.Serializable { private String name; private int age; // 注意此处没有提供无参数的构造器! public Person(String name, int age) { System.out.println("有参数的构造器"); this.name = name; this.age = a…
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class ReadFromProcess { public static void main(String[] args) throws IOException { Process p = Runtime.getRuntime().exec("javac"); var br = new…
output redirectionOut: public class RedirectOut { public static void main(String[] args) throws FileNotFoundException { try { var ps = new PrintStream(new FileOutputStream("out.txt")); System.setOut(ps); System.out.println("普通字符串"); Sy…
import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.PushbackReader; public class PushbackTest { public static void main(String[] args) { try { ); { ]; var lastContent = ""; ; ){ ,hasRead);…
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class KeyinTest { public static void main(String[] args) throws IOException { var reader = new InputStreamReader(System.in); var br = new BufferedRead…
有点重定向使用的味道 import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintStream; public class PrintStreamTest { public static void main(String[] args) { try { var fos = new FileOutputStream("test.txt"); var ps = new…
import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; public class FileOutputStreamTest { public static void main(String[] args) { try { var fis = new FileInputStream("FileI…
import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.nio.charset.Charset; public class FileReaderTest { public static void main(String[] args) { try { var fr = new FileReader("FileReaderTest.java&qu…
public class FileInputStreamTest { public static void main(String[] args) throws IOException { var fis = new FileInputStream("FileInputStreamTest.java"); ]; ; ){ System.,hasRead)); } fis.close(); } }…
import java.io.File; public class FilenameFilterTest { public static void main(String[] args) { var file = new File("."); String[] nameList = file.list(((dir, name) -> name.endsWith(".java") || new File(name).isDirectory())); for (v…
import java.io.File; import java.io.IOException; public class FileTest { public static void main(String[] args) throws IOException { var file = new File("."); System.out.println(file.getName()); System.out.println(file.getParent()); System.out.p…
import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.InputEvent; public class BindKeyTest { JFrame jf = new JFrame("test keyboard bind"); JTextArea jta = ,); JButton jb = new JButton("发送");…
import javax.swing.*; import java.awt.*; import java.awt.event.ActionListener; import java.awt.event.InputEvent; public class SwingComponent { JFrame f = new JFrame("test"); Icon okIcon = new ImageIcon("ico/ok.png"); JButton ok = new J…