java_i_o_streams

Java I/O Streams

Return to Java Reading and Writing Files

Using I/O Streams

I/O streams are all about reading/writing data, so it shouldn't be a surprise that the most important methods are read() and write(). Both InputStream and Reader declare a read() method to read byte data from an I/O stream. Likewise, OutputStream and Writer both define a write() method to write a byte to the stream:

The following copyStream() methods show an example of reading all of the values of an InputStream and Reader and writing them to an OutputStream and Writer, respectively. In both examples, -1 is used to indicate the end of the stream.

void copyStream(InputStream in, OutputStream out) throws IOException { int b; while 1) != -1) { out.write(b); } } void copyStream(Reader in, Writer out) throws IOException { int b; while 2) != -1) { out.write(b); } }

Hold on. We said we are reading and writing bytes, so why do the methods use int instead of byte? Remember, the byte data type has a range of 256 characters. They needed an extra value to indicate the end of an I/O stream. The authors of Java decided to use a larger data type, int, so that special values like -1 would indicate the end of an I/O stream. The output stream classes use int as well, to be consistent with the input stream classes.

Reading and writing one byte at a time isn't a particularly efficient way of doing this. Luckily, there are overloaded methods for reading and writing multiple bytes at a time. The offset and length values are applied to the array itself. For example, an offset of 3 and length of 5 indicates that the stream should read up to five bytes/characters of data and put them into the array starting with position 3. Let's look at an example:

10: void copyStream(InputStream in, OutputStream out) throws IOException { 11: int batchSize = 1024; 12: var buffer = new byte[batchSize]; 13: int lengthRead; 14: while 3)> 0) { 15: out.write(buffer, 0, lengthRead); 16: out.flush(); 17: }

Instead of reading the data one byte at a time, we read and write up to 1024 bytes at a time on line 14. The return value lengthRead is critical for determining whether we are at the end of the stream and knowing how many bytes we should write into our output stream.

Unless our file happens to be a multiple of 1024 bytes, the last iteration of the while loop will write some value less than 1024 bytes. For example, if the buffer size is 1,024 bytes and the file size is 1,054 bytes, the last read will be only 30 bytes. If we ignored this return value and instead wrote 1,024 bytes, 994 bytes from the previous loop would be written to the end of the file.

We also added a flush() method on line 16 to reduce the amount of data lost if the application terminates unexpectedly. When data is written to an output stream, the underlying operating system does not guarantee that the data will make it to the file system immediately. The flush() method requests that all accumulated data be written immediately to disk. It is not without cost, though. Each time it is used, it may cause a noticeable delay in the application, especially for large files. Unless the data that you are writing is extremely critical, the flush() method should be used only intermittently. For example, it should not necessarily be called after every write, as it is in this example.

Equivalent methods exist on Reader and Writer, but they use char rather than byte, making the equivalent copyStream() method very similar.

The previous example makes reading and writing a file look like a lot to think about. That's because it only uses low-level I/O streams. Let's try again using high-level streams.

26: void copyTextFile(File src, File dest) throws IOException { 27: try (var reader = new BufferedReader(new FileReader(src)); 28: var writer = new BufferedWriter(new FileWriter(dest))) { 29: String line = null; 30: while 4) != null) { 31: writer.write(line); 32: writer.newLine(); 33: } } }

The key is to choose the most useful high-level classes. In this case, we are dealing with a File, so we want to use a FileReader and FileWriter. Both classes have constructors that can take either a String representing the location or a File directly.

If the source file does not exist, a FileNotFoundException, which inherits IOException, will be thrown. If the destination file already exists, this implementation will overwrite it. We can pass an optional boolean second parameter to FileWriter for an append flag if we want to change this behavior.

We also chose to use a BufferedReader and BufferedWriter so we can read a whole line at a time. This gives us the benefits of reading batches of characters on line 30 without having to write custom logic. Line 31 writes out the whole line of data at once. Since reading a line strips the line breaks, we add those back on line 32. Lines 27 and 28 demonstrate chaining constructors. The try-with-resources constructor takes care of closing all the objects in the chain.

Now imagine that we wanted byte data instead of characters. We would need to choose different high-level classes: BufferedInputStream, BufferedOutputStream, FileInputStream, and FileOuputStream. We would call readAllBytes() instead of readLine() and store the result in a byte[] instead of a String. Finally, we wouldn't need to handle new lines since the data is binary.

We can do a little better than BufferedOutputStream and BufferedWriter by using a PrintStream and PrintWriter. These classes contain four key methods. The print() and println() methods print data with and without a new line, respectively. There are also the format() and printf() methods, which we describe in the section on user interactions.

void copyTextFile(File src, File dest) throws IOException { try (var reader = new BufferedReader(new FileReader(src)); var writer = new PrintWriter(new FileWriter(dest))) { String line = null; while 5) != null) writer.println(line); } }

While we used a String, there are numerous overloaded versions of println(), which take everything from primitives and String values to objects. Under the covers, these methods often just perform String.valueOf().

The print stream classes have the distinction of being the only I/O stream classes we cover that do not have corresponding input stream classes. And unlike other OutputStream classes, PrintStream does not have Output in its name.

It may surprise you that you've been regularly using a PrintStream throughout this book. Both System.out and System.err are PrintStream objects. Likewise, System.in, often useful for reading user input, is an InputStream.

Unlike the majority of the other I/O streams we've covered, the methods in the print stream classes do not throw any checked exceptions. If they did, you would be required to catch a checked exception any time you called System.out.print()!

The line separator is \n or \r\n, depending on your operating system. The println() method takes care of this for you. If you need to get the character directly, either of the following will return it for you:

System.getProperty(“line.separator”); System.lineSeparator();

Java Vocabulary List (Sorted by Popularity)

Java Programming Language, Java Virtual Machine (JVM), Java Development Kit (JDK), Java Runtime Environment (JRE), Java Class, Java Interface, Java Method, Java Object, Java Package, Java String, Java Integer, Java Array, Java List, Java Map, Java Set, Java Exception, Java Thread, Java Synchronization, Java Generic, Java Annotation, Java Stream, Java Lambda Expression, Java Inheritance, Java Polymorphism, Java Encapsulation, Java Abstraction, Java Access Modifier, Java Constructor, Java Overloading, Java Overriding, Java Collection Framework, Java ArrayList, Java HashMap, Java HashSet, Java LinkedList, Java TreeMap, Java TreeSet, Java Iterator, Java Enumeration, Java File, Java InputStream, Java OutputStream, Java Reader, Java Writer, Java BufferedReader, Java BufferedWriter, Java PrintWriter, Java PrintStream, Java Scanner, Java StringBuilder, Java StringBuffer, Java Character, Java Boolean, Java Double, Java Float, Java Byte, Java Short, Java Long, Java BigInteger, Java BigDecimal, Java ClassLoader, Java Reflection, Java Proxy, Java Dynamic Proxy, Java Inner Class, Java Static Nested Class, Java Anonymous Class, Java Enum, Java Autoboxing, Java Auto-Unboxing, Java Garbage Collection, Java Memory Model, Java Just-In-Time Compilation, Java Classpath, Java Module, Java Module Path, Java Record, Java Sealed Class, Java Switch Expression, Java Pattern Matching for instanceof, Java Text Block, Java Var Keyword, Java Interface Default Method, Java Interface Static Method, Java Functional Interface, Java SAM (Single Abstract Method) Interface, Java Optional, Java Stream API, Java Collectors, Java Parallel Streams, Java Concurrency Package, Java Executor, Java ExecutorService, Java Future, Java CompletableFuture, Java ForkJoinPool, Java ReentrantLock, Java Semaphore, Java CountDownLatch, Java CyclicBarrier, Java Phaser, Java BlockingQueue, Java ConcurrentHashMap, Java AtomicInteger, Java AtomicLong, Java AtomicReference, Java AtomicBoolean, Java Lock Interface, Java ReadWriteLock, Java Condition, Java ThreadLocal, Java Synchronized Keyword, Java Volatile Keyword, Java Notify, Java Wait, Java Monitor, Java ReentrantReadWriteLock, Java ConcurrentLinkedQueue, Java PriorityQueue, Java Deque, Java ArrayDeque, Java SortedMap, Java SortedSet, Java NavigableMap, Java NavigableSet, Java EnumSet, Java EnumMap, Java WeakHashMap, Java LinkedHashMap, Java LinkedHashSet, Java IdentityHashMap, Java TreeMap Comparator, Java HashCode, Java Equals Method, Java CompareTo Method, Java Cloneable Interface, Java Serializable Interface, Java Externalizable Interface, Java Serialization Mechanism, Java ObjectOutputStream, Java ObjectInputStream, Java Transient Keyword, Java Persistence, Java JDBC (Java Database Connectivity), Java SQL Package, Java PreparedStatement, Java ResultSet, Java DriverManager, Java Connection, Java Statement, Java CallableStatement, Java RowSet, Java Bean, Java PropertyDescriptor, Java Introspector, Java BeanInfo, Java Enterprise Edition, Java Servlet, Java ServletContext, Java HttpServlet, Java HttpServletRequest, Java HttpServletResponse, Java Session, Java Filter, Java Listener, Java JSP (Java Server Pages), Java Expression Language, Java JSTL (JavaServer Pages Standard Tag Library), Java JDBC RowSet, Java DataSource, Java JNDI (Java Naming and Directory Interface), Java RMI (Remote Method Invocation), Java RMI Registry, Java RMI Stub, Java RMI Skeleton, Java RMI Remote Interface, Java CORBA Support, Java IDL, Java NamingException, Java InitialContext, Java Context Lookup, Java Message Service (JMS), Java Mail API, Java Bean Validation, Java Security Manager, Java Policy, Java Permission, Java AccessController, Java PrivilegedAction, Java KeyStore, Java TrustStore, Java SSLContext, Java Cipher, Java MessageDigest, Java KeyFactory, Java SecretKey, Java PublicKey, Java PrivateKey, Java Certificate, Java SecureRandom, Java SecureClassLoader, Java GSS-API (Generic Security Services), Java SASL (Simple Authentication and Security Layer), Java JAAS (Java Authentication and Authorization Service), Java Kerberos Integration, Java PKI (Public Key Infrastructure), Java JCE (Java Cryptography Extension), Java JCA (Java Cryptography Architecture), Java AWT (Abstract Window Toolkit), Java Swing, Java JFrame, Java JPanel, Java JLabel, Java JButton, Java JTextField, Java JTextArea, Java JScrollPane, Java JList, Java JComboBox, Java JTable, Java JTree, Java JDialog, Java JOptionPane, Java JProgressBar, Java JSlider, Java JSpinner, Java BoxLayout, Java BorderLayout, Java FlowLayout, Java GridLayout, Java GridBagLayout, Java CardLayout, Java LayoutManager, Java Drag and Drop, Java Clipboard, Java ImageIO, Java BufferedImage, Java Graphics2D, Java Font, Java Color, Java GradientPaint, Java TexturePaint, Java Stroke, Java Shape, Java AffineTransform, Java Path2D, Java BasicStroke, Java RenderingHints, Java GraphicsEnvironment, Java Robot, Java PrintService, Java PrinterJob, Java Paint Event, Java SwingUtilities, Java Pluggable LookAndFeel, Java Metal LookAndFeel, Java Nimbus LookAndFeel, Java Accessibility API, Java Sound API, Java MIDI, Java Clip, Java AudioInputStream, Java Sequencer, Java Synthesizer, Java Line, Java Port, Java Mixer, Java DataLine, Java Applet, Java Web Start, Java FX (JavaFX), Java SceneGraph, Java Node (JavaFX), Java Stage (JavaFX), Java Scene (JavaFX), Java Pane (JavaFX), Java GridPane, Java BorderPane, Java HBox, Java VBox, Java StackPane, Java AnchorPane, Java FlowPane, Java TilePane, Java Label (JavaFX), Java Button (JavaFX), Java TextField (JavaFX), Java TextArea (JavaFX), Java ChoiceBox, Java ComboBox (JavaFX), Java ListView, Java TableView, Java TreeView, Java WebView, Java Observable, Java Property (JavaFX), Java Binding (JavaFX), Java CSS (JavaFX), Java FXML, Java MediaPlayer, Java SwingNode, Java HTMLEditor (JavaFX), Java Concurrency in JavaFX, Java ScheduledExecutorService, Java Timer, Java TimerTask, Java ThreadPoolExecutor, Java WorkStealingPool, Java Callable, Java Runnable, Java FutureTask, Java LockSupport, Java Phaser Parties, Java Thread Dump, Java Heap Dump, Java Flight Recorder, Java Mission Control, Java JVMTI (JVM Tool Interface), Java JMX (Java Management Extensions), Java MBean, Java MBeanServer, Java MXBean, Java GarbageCollectorMXBean, Java MemoryMXBean, Java OperatingSystemMXBean, Java ThreadMXBean, Java CompilationMXBean, Java ClassLoadingMXBean, Java PlatformManagedObject, Java Instrumentation API, Java Attach API, Java JVMDebugger, Java JDWP (Java Debug Wire Protocol), Java JDI (Java Debug Interface), Java JShell, Java Scripting API, Java Nashorn (JavaScript Engine), Java XML Processing, Java DOM Parser, Java SAX Parser, Java StAX Parser, Java JAXB (Java Architecture for XML Binding), Java JAXP (Java API for XML Processing), Java SOAP, Java JAX-WS (Java API for XML Web Services), Java RESTful Web Services (JAX-RS), Java JSON Processing (JSON-P), Java JSON Binding (JSON-B), Java CDI (Contexts and Dependency Injection), Java EJB (Enterprise JavaBeans), Java JMS (Java Message Service), Java JTA (Java Transaction API), Java Bean Validation (JSR 380), Java Dependency Injection Frameworks, Java Spring Framework, Java Spring Boot, Java Hibernate (Java Persistence Framework), Java JPA (Java Persistence API), Java JAX-RPC (Java API for XML-based RPC), Java AppServer, Java GlassFish, Java WildFly, Java Liberty Profile, Java Tomcat, Java Jetty, Java Undertow, Java OSGi (Open Service Gateway Initiative), Java Pax Exam, Java RAP (Remote Application Platform), Java RCP (Rich Client Platform), Java Equinox, Java Tycho Build, Java Lombok, Java Guava, Java SLF4J (Simple Logging Facade for Java), Java Logback, Java JUL (Java Util Logging), Java Log4j, Java Commons Collections, Java Commons IO, Java Commons Lang, Java HTTPClient, Java URLConnection, Java URI Class, Java URL Class, Java Cookie Handler, Java HTTPServer, Java WebSocket API, Java AppletViewer, Java RMIClassLoader, Java JVMPauseDetector, Java Memory Settings, Java System Properties, Java Environment Variables (As Accessed by Java), Java ServiceLoader, Java SPI (Service Provider Interface), Java Instrumentation Rewriting, Java Agent Attaching, Java Runtime Exec, Java ProcessHandle, Java ProcessBuilder, Java ScriptingEngineManager, Java ScriptEngine, Java ScriptContext, Java CompiledScript, Java FX Application Thread, Java FXProperty, Java FXObservableValue, Java FXKeyFrame, Java FXTimeline, Java FXTransition, Java FXImageView, Java FXCanvas, Java FX3D Features, Java AOT Compilation (jaotc), Java GraalVM Integration, Java JNI (Java Native Interface), Java NIO (Non-Blocking I/O), Java Path, Java Files Class, Java FileSystem, Java FileChannel, Java AsynchronousFileChannel, Java Socket, Java ServerSocket, Java DatagramSocket, Java MulticastSocket, Java SocketChannel, Java ServerSocketChannel, Java DatagramChannel, Java Pipe, Java FileLock, Java MappedByteBuffer, Java CharsetDecoder, Java CharsetEncoder, Java SecretKeySpec, Java KeySpec, Java KeyPair, Java KeyAgreement, Java KeyGenerator, Java Mac (Message Authentication Code), Java PolicySpi, Java SecureRandomSpi, Java CertPath, Java CertPathBuilder, Java CertPathValidator, Java TrustManager, Java KeyManager, Java SSLSession, Java SSLSocket, Java SSLServerSocket, Java SSLEngine, Java SSLParameters, Java HttpsURLConnection, Java DomainCombiner, Java Principal, Java Subject, Java LoginContext, Java CallbackHandler, Java TextField (Swing), Java TextPane, Java StyledDocument, Java AttributeSet, Java StyleConstants, Java AbstractDocument, Java DocumentFilter, Java Caret, Java Highlighter, Java UndoManager, Java DefaultStyledDocument, Java ViewFactory, Java EditorKit, Java KeyStroke, Java ActionMap, Java InputMap, Java RootPane, Java GlassPane, Java LayeredPane, Java MenuBar, Java MenuItem, Java JMenu, Java JMenuItem, Java JCheckBoxMenuItem, Java JRadioButtonMenuItem, Java PopupMenu, Java Popup, Java TooltipManager, Java DesktopManager, Java InternalFrame, Java InternalFrameUI, Java InternalFrameAdapter, Java DockingFrames, Java SystemTray, Java TrayIcon, Java Robot Class, Java PrintServiceLookup, Java FlavorMap, Java Transferable, Java DataFlavor, Java DragGestureRecognizer, Java DropMode, Java DropTargetAutoScroll, Java DropTargetContext, Java DropTargetListener, Java DropTargetDragEvent, Java DropTargetDropEvent, Java BasicLookAndFeel Class, Java SynthLookAndFeel, Java UIDefaults, Java UIManager, Java ClientPropertyKey, Java ImageIOSpi, Java ImageWriter, Java ImageReader, Java ImageInputStream, Java ImageOutputStream, Java IIOMetadata, Java BufferedImageOp, Java ColorModel, Java WritableRaster, Java IndexColorModel, Java Raster, Java RenderedImage, Java WritableRenderedImage, Java ImageTranscoder, Java ImageWriterSpi, Java ImageReaderSpi, Java Soundbank, Java MidiChannel, Java MidiDevice, Java MidiEvent, Java Sequence, Java MidiFileFormat, Java SoundFont, Java AudioSystem, Java AudioFormat, Java DataLine.Info, Java LineEvent, Java LineListener, Java Clip Class, Java SourceDataLine, Java TargetDataLine, Java Port.Info, Java Mixer.Info, Java Gervill (SoftSynthesizer), Java AccessBridge, Java AWTEvent, Java KeyEvent, Java MouseEvent, Java FocusEvent, Java WindowEvent, Java ComponentEvent, Java AdjustmentEvent, Java ContainerEvent, Java InputMethodEvent, Java HierarchyEvent, Java InvocationEvent, Java PaintEvent, Java DropTargetEvent, Java Peer Interface, Java AWTEventMulticaster, Java Toolkit, Java Desktop, Java GraphicsConfiguration, Java GraphicsDevice, Java AWTKeyStroke, Java TextHitInfo, Java TextLayout, Java TextAttribute, Java FontRenderContext, Java AttributedString, Java LineBreakMeasurer, Java Bidi, Java BreakIterator, Java Collator, Java Locale, Java ResourceBundle, Java Formatter, Java Format Conversion, Java SimpleDateFormat, Java DecimalFormat, Java MessageFormat, Java ChoiceFormat, Java ScannerDelimiter, Java System.Logger, Java Logger, Java Level, Java LogRecord, Java ConsoleHandler, Java FileHandler, Java MemoryHandler, Java SocketHandler, Java SimpleFormatter, Java XMLFormatter, Java Preferences, Java PreferenceChangeEvent, Java NodeChangeEvent, Java PrinterException, Java PrinterAbortException, Java PrintException, Java PrintQuality, Java PrintServiceAttribute, Java ServiceUI, Java Pageable, Java Printable, Java Book, Java TablePrintable, Java StreamPrintService, Java StreamPrintServiceFactory, Java Filer (Annotation Processing), Java Messager, Java ProcessingEnvironment, Java Element, Java ElementKind, Java ElementVisitor, Java PackageElement, Java TypeElement, Java VariableElement, Java ExecutableElement, Java AnnotationMirror, Java AnnotationValue, Java AnnotationProcessor, Java RoundEnvironment, Java TypeMirror, Java DeclaredType, Java ArrayType, Java TypeVariable, Java WildcardType, Java NoType, Java ErrorType, Java UnionType, Java IntersectionType, Java JavacTool, Java StandardJavaFileManager, Java Diagnostic, Java DiagnosticCollector, Java ForwardingJavaFileManager, Java ForwardingJavaFileObject, Java ForwardingJavaFileObject, Java SPI ServiceLoader, Java ToolProvider, Java DocumentationTool, Java JavaCompiler, Java JShellTool, Java DiagnosticListener, Java CompilationTask, Java ModuleElement, Java ModuleLayer, Java ModuleDescriptor, Java ModuleFinder

OLD before GPT Pro: Abstract Classes, Abstract Methods, Abstract Window Toolkit, Access Control Exception, Access Modifiers, Accessible Object, AccessController Class, Action Event, Action Listener, Action Performed Method, Adapter Classes, Adjustment Event, Adjustment Listener, Annotation Processing Tool, Annotations, AnnotationTypeMismatchException, Anonymous Classes, Applet Class, Applet Context, Applet Lifecycle Methods, Application Class Data Sharing, Array Blocking Queue, Array Index Out of Bounds Exception, Array List, Array Store Exception, Arrays Class, Assertion Error, Assertions, Assignment Operator, Asynchronous File Channel, Atomic Boolean, Atomic Integer, Atomic Long, Atomic Reference, Attribute Set, Audio Clip, Authentication Mechanisms, Auto Closeable Interface, Auto Boxing, AWT Components, AWT Event Queue, AWT Listeners, AWT Toolkit, Backing Store, Background Compilation, Batch Updates, Bean Context, Bean Descriptors, Bean Info, Big Decimal Class, Big Integer Class, Binary Compatibility, Binding Utilities, Bit Set Class, Bitwise Operators in Java, Blocking Queue Interface, Boolean Class, Bounded Wildcards, Breakpoint, Buffered Input Stream, Buffered Output Stream, Buffered Reader, Buffered Writer, BufferOverflowException, BufferUnderflowException, Button Class, Byte Array Input Stream, Byte Array Output Stream, Byte Order, ByteBuffer Class, Bytecode Instructions, Bytecode Verifier, Callable Interface, Callable Statement, Calendar Class, Canvas Class, Card Layout, Caret Listener, Case Sensitivity in Java, Casting in Java, Catch Block, Certificate Exception, Character Class, Character Encoding, Character Set, Character.UnicodeBlock, Charset Class, Checked Exceptions, Checkbox Class, Choice Component, Class Class, Class Files, Class Loader, Class Loader Hierarchy, Class Loading Mechanism, Class Not Found Exception, Class Object, Class Path, ClassCastException, ClassCircularityError, ClassFormatError, ClassLoader, ClassNotFoundException, Clone Method, CloneNotSupportedException, Cloneable Interface, Clipboard Class, Cloneable Interface, ClosedChannelException, Collections Framework, Collections Utility Class, Collector Interface, Collectors Class, Color Class, Column Major Order, Comparable Interface, Comparator Interface, Compiler API, Compiler Directives, Compiler Optimization, Component Class, Component Event, Component Listener, Composite Pattern, ConcurrentHashMap, ConcurrentLinkedQueue, ConcurrentModificationException, ConcurrentNavigableMap, ConcurrentSkipListMap, ConcurrentSkipListSet, Condition Interface, Connection Interface, Console Class, Constructor Overloading, Consumer Interface, Container Class, ContainerEvent, Content Handler, ContentHandlerFactory, Context Class Loader, Continue Statement, Control Flow Statements, CountDownLatch Class, CRC32 Class, Credential Management, Critical Section, CyclicBarrier Class, Daemon Threads, Data Class, Data Input Interface, Data Input Stream, Data Output Interface, Data Output Stream, Data Truncation Exception, Date Class, Daylight Saving Time Handling, Deadlock in Java, Debugging Techniques, DecimalFormat Class, Default Methods in Interfaces, Deflater Class, Deprecated Annotation, Design Patterns in Java, Desktop Class, Diamond Operator, Dialog Class, Dictionary Class, DigestInputStream, DigestOutputStream, Direct Byte Buffer, DirectoryStream Interface, Document Object Model, DOM Parsing in Java, Double Brace Initialization, Double Class, Drag and Drop API, Driver Manager, Drop Shadow Effect, Dynamic Binding, Dynamic Proxy Classes, Element Interface, Ellipse2D Class, EmptyStackException, Encapsulation in Java, Enum Classes, Enum Constant, EnumSet Class, Enumeration Interface, EOFException, Error Handling in Java, Error Prone Practices, Event Delegation Model, Event Handling Mechanism, Event Listener Interfaces, Event Object, Event Queue, EventQueue Class, Exception Chaining, Exception Handling Mechanism, Executable Jar Files, Executor Interface, Executor Service, Executors Class, Expression Evaluation, Extends Keyword, Externalizable Interface, File Class, File Channel, File Descriptor, File Filter Interface, File Input Stream, File Lock Mechanism, File Output Stream, File Permission, File Reader, File Writer, FileDialog Class, FilenameFilter Interface, FileNotFoundException, Final Classes, Final Keyword, Finally Block, Finalize Method, Finalizer Guardian Idiom, Float Class, Flow Layout, Flow API, Focus Listener, Font Class, For Each Loop, ForkJoinPool Class, Formatter Class, Frame Class, Functional Interfaces, Future Interface, FutureTask Class, Garbage Collection Mechanism, Garbage Collector, Generics in Java, Generic Methods, Generic Types, Geometry Classes, Glyph Vector, GradientPaint Class, Graphics Class, Graphics2D Class, Grid Bag Constraints, Grid Bag Layout, Grid Layout, GregorianCalendar Class, Group Layout, GUI Components in Java, GZIPInputStream, GZIPOutputStream, Hash Collision, Hash Function, Hash Map Class, Hash Set Class, Hashtable Class, HashCode Method, Headless Exception, Heap Memory, Hello World Program in Java, Hierarchical Inheritance, High-Level Concurrency API, HTTP Client in Java, HTTP Server in Java, Icon Interface, Identifier Naming Convention, If Statement, IllegalArgumentException, IllegalMonitorStateException, IllegalStateException, IllegalThreadStateException, Image Class, ImageIcon Class, Immutable Classes, Import Statement, InaccessibleObjectException, Inheritance in Java, InitialContext Class, Inner Classes, Input Method Framework, Input Stream, InputStreamReader Class, Instance Initializer Block, Instance Variables, InstantiationException, Integer Class, Integer Overflow and Underflow, InterruptedException, InterruptedIOException, Interface in Java, InternalError, Internationalization, IO Exception, IO Streams in Java, Iterable Interface, Iterator Interface, Jar Entry, Jar File, JarInputStream Class, JarOutputStream Class, Java Access Bridge, Java Annotations, Java API Documentation, Java Applets, Java Archive (JAR), Java Beans, Java Bytecode, Java Class Library, Java Collections Framework, Java Community Process, Java Compiler, Java Database Connectivity (JDBC), Java Development Kit (JDK), Java Documentation Comments, Java Flight Recorder, Java Garbage Collector, Java Generics, Java Memory Model, Java Native Interface (JNI), Java Naming and Directory Interface (JNDI), Java Network Launching Protocol (JNLP), Java Platform, Java Plugin, Java Reflection API, Java Remote Method Invocation (RMI), Java Runtime Environment (JRE), Java Security Manager, Java Serialization, Java Server Pages (JSP), Java Stream API, Java Swing, Java Virtual Machine (JVM), Java Web Start, JavaFX Platform, javax Package, Javadoc Tool, JAR Signing Mechanism, JDBC API, JDBC Drivers, JFrame Class, JIT Compiler, JLabel Class, JLayeredPane Class, JList Component, JMenu Component, JOptionPane Class, JPanel Class, JPasswordField Component, JProgressBar Component, JScrollBar Component, JScrollPane Component, JSeparator Component, JSlider Component, JSplitPane Component, JTabbedPane Component, JTable Component, JTextArea Component, JTextField Component, JTextPane Component, JToolBar Component, JTree Component, JVM Arguments, JVM Memory Model, Key Event, Key Listener Interface, Key Stroke Class, KeyException, KeySpec Interface, Keyword in Java, Label Class, Lambda Expressions in Java, Layout Manager, LayoutManager2 Interface, Lazy Initialization, Leaf Nodes, Legacy Classes in Java, LineNumberReader Class, Linked Blocking Queue, Linked Hash Map, Linked Hash Set, Linked List Class, List Interface, List Iterator Interface, Listener Interfaces in Java, Load Factor in HashMap, Locale Class, Lock Interface, Logger Class, Logging API in Java, Long Class, Main Method in Java, MalformedURLException, Map Interface, Map.Entry Interface, Marker Interface, Math Class, Media Tracker, Memory Leak in Java, Memory Management in Java, Menu Class, Message Digest, Method Chaining, Method Overloading, Method Overriding, Methods in Java, MIDI Devices in Java, Mouse Adapter Class, Mouse Event, Mouse Listener Interface, Multi-Catch Exception, Multi-Level Inheritance, Multicast Socket, Multidimensional Arrays, Mutable Objects in Java, Naming Convention in Java, Native Methods, Navigable Map, Navigable Set, Nested Classes in Java, Network Interface Class, NoClassDefFoundError, NoSuchFieldException, NoSuchMethodException, Non-Blocking IO (NIO), Null Pointer Exception, Number Class, Number Format Exception, NumberFormat Class, Object Class, Object Cloning, Object Input Stream, Object Oriented Programming, Object Output Stream, Object Serialization in Java, Observer Pattern, Observable Class, OpenGL in Java, Optional Class, OutOfMemoryError, Override Annotation, Package Declaration, Packages in Java, Paint Interface, Panel Class, Parallel Garbage Collector, Parameter Passing in Java, ParseException, Path Interface, Pattern Class, Piped Input Stream, Piped Output Stream, PixelGrabber Class, Point Class, Polymorphism in Java, Prepared Statement, Primitive Data Types in Java, PrintStream Class, PrintWriter Class, Priority Blocking Queue, Priority Queue Class, Private Access Modifier, Process Class, Process Builder Class, Progress Monitor Class, Properties Class, Protected Access Modifier, Proxy Class, Public Access Modifier, Queue Interface, RadioButton Class, Random Access File, Reader Class, ReadWriteLock Interface, Rectangle Class, Recursive Methods, Reflection API in Java, Reference Queue, Regular Expressions in Java, Remote Method Invocation (RMI), Render Quality, Repeatable Annotations, Resource Bundle Class, Resource Leak in Java, ResultSet Interface, ResultSetMetaData Interface, Retry Logic in Java, Return Statement in Java, Runnable Interface, Runtime Class, Runtime Error, Runtime Exception, Runtime Permissions, Runtime Polymorphism, Scanner Class, Scheduling in Java, Script Engine, Scroll Bar Component, Scroll Pane Component, Security Exception, Security Manager, Semaphore Class, Sequence Input Stream, Serializable Interface, ServerSocket Class, Service Loader, Set Interface, Setter Methods, Shared Memory in Java, Short Class, Single Inheritance, Singleton Pattern in Java, Socket Class, SocketTimeoutException, Sorted Map, Sorted Set, Splash Screen, Spring Framework, SQLException, SSL Socket, Stack Class, StackOverflowError, Standard Edition of Java, StandardOpenOption, Statement Interface, StreamTokenizer Class, Strictfp Keyword, String Buffer Class, String Builder Class, String Class, String Constant Pool, StringIndexOutOfBoundsException, String Interning, String Literal in Java, String Pool in Java, String Tokenizer Class, Strong Typing in Java, Structural Patterns, Stub Class, Subclasses in Java, Superclass in Java, Supplier Interface, Support Classes, Swing Components, Swing Timer, Switch Statement in Java, Synchronized Block, Synchronized Method, System Class, System Properties in Java, Tab Pane Component, Table Model Interface, TCP Connection in Java, Template Method Pattern, Text Area Component, Text Field Component, Text Listener Interface, Thread Class, Thread Group, Thread Interruption, Thread Local Class, Thread Priority, Thread Safety in Java, Thread Scheduling, Throwable Class, Time Zone Class, Timer Class, Timer Task Class, Toolkit Class, ToolTip Manager, Transferable Interface, Transient Keyword, Tree Map Class, Tree Set Class, Try With Resources Statement, Type Erasure in Java, Type Inference in Java, Type Parameters, UI Manager Class, Unary Operator Interface, Unchecked Exceptions, UndeclaredThrowableException, Unicode Support in Java, Unmodifiable Collection, Unsafe Class, URL Class, URLConnection Class, URLDecoder Class, URLEncoder Class, URLStreamHandler Class, URLClassLoader Class, User Interface Components, Varargs in Java, Variable Arguments, Variable Scope in Java, Vector Class, Vendor-Specific Extensions, Viewport Class, Virtual Machine in Java, Volatile Keyword, Wait and Notify Methods, Weak Hash Map, Weak Reference, While Loop in Java, Wildcard Generic Types, Window Adapter Class, Window Event, Window Listener Interface, Wrapper Classes in Java, Write Once Run Anywhere, XML Binding in Java, XML Parsing in Java, XML Schema in Java, XPath Expression in Java, XSLT Transformation in Java, Yield Method in Thread, Zip Entry, Zip File, Zip Input Stream, Zip Output Stream, ZoneId Class, ZoneOffset Class

Java: Java Best Practices (Effective Java), Java Fundamentals, Java Inventor - Java Language Designer: James Gosling of Sun Microsystems, Java Docs, JDK, JVM, JRE, Java Keywords, JDK 17 API Specification, java.base, Java Built-In Data Types, Java Data Structures - Java Algorithms, Java Syntax, Java OOP - Java Design Patterns, Java Installation, Java Containerization, Java Configuration, Java Compiler, Java Transpiler, Java IDEs (IntelliJ - Eclipse - NetBeans), Java Development Tools, Java Linter, JetBrains, Java Testing (JUnit, Hamcrest, Mockito), Java on Android, Java on Windows, Java on macOS, Java on Linux, Java DevOps - Java SRE, Java Data Science - Java DataOps, Java Machine Learning, Java Deep Learning, Functional Java, Java Concurrency, Java History,

Java Bibliography (Effective Java, Head First Java, Java - A Beginner's Guide by Herbert Schildt, Java Concurrency in Practice, Clean Code by Robert C. Martin, Java - The Complete Reference by Herbert Schildt, Java Performance by Scott Oaks, Thinking in Java, Java - How to Program by Paul Deitel, Modern Java in Action, Java Generics and Collections by Maurice Naftalin, Spring in Action, Java Network Programming by Elliotte Rusty Harold, Functional Programming in Java by Pierre-Yves Saumont, Well-Grounded Java Developer, Second Edition, Java Module System by Nicolai Parlog), Manning Java Series, Java Glossary - Glossaire de Java - French, Java Topics, Java Courses, Java Security - Java DevSecOps, Java Standard Library, Java Libraries, Java Frameworks, Java Research, Java GitHub, Written in Java, Java Popularity, Java Awesome List, Java Versions. (navbar_java and navbar_java_detailed - see also navbar_jvm, navbar_java_concurrency, navbar_java_standard_library, navbar_java_libraries, navbar_java_best_practices, navbar_openjdk, navbar_java_navbars, navbar_kotlin)


Cloud Monk is Retired ( for now). Buddha with you. © 2025 and Beginningless Time - Present Moment - Three Times: The Buddhas or Fair Use. Disclaimers

SYI LU SENG E MU CHYWE YE. NAN. WEI LA YE. WEI LA YE. SA WA HE.


1) , 2)
b = in.read(
3)
lengthRead = in.read(buffer, 0, batchSize
4) , 5)
line = reader.readLine(
java_i_o_streams.txt · Last modified: 2025/02/01 06:48 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki