This document discusses input/output (I/O) in Java. It covers handling files and directories using the File class, understanding character-based and byte-based streams, and examples of character and binary file input/output. Character I/O uses Readers and Writers, while binary I/O uses DataStreams. A BufferedReader is required to read full lines of text from a file. Formatting output is handled using DecimalFormat since Java has no printf method. Streams can be chained together, such as a FileOutputStream chained to a DataOutputStream for binary file output.
Unit 10 discusses files and file handling in C. It introduces the concept of data files, which allow data to be stored on disks and accessed whenever needed. There are two main types of data files: standard/high-level files and system/low-level files. Standard files are further divided into text and binary files.
To read from or write to files, a program must first open the file. This establishes a link between the program and operating system. Various library functions allow reading, writing, and processing file contents, such as fopen() to open a file, fread() and fwrite() for record input/output, and fseek() to move the file pointer to different positions for direct access of
The document discusses file handling in C programming. It explains that console I/O functions use keyboard and monitor for input and output but the data is lost when the program terminates. Files provide a permanent way to store and access data. The document then describes different file handling functions like fopen(), fclose(), fgetc(), fputc(), fprintf(), fscanf() for reading from and writing to files. It also discusses opening files in different modes, reading and writing characters and strings to files, and using formatted I/O functions for files.
File handling in C programming uses file streams as the means of communication between programs and data files. The input stream extracts data from files and supplies it to the program, while the output stream stores data from the program into files. To handle file input/output, header file fstream.h is included, which contains ifstream and ofstream classes. Common file operations include opening, reading, writing, and closing files using functions like fopen(), fgetc(), fputs(), fclose(), and checking for end-of-file conditions. Files can be opened in different modes like read, write, append depending on the operation to be performed.
The document discusses file handling in C using basic file I/O functions. It explains that files must be opened using fopen() before reading or writing to them. The file pointer returned by fopen() is then used to perform I/O operations like fscanf(), fprintf(), etc. It is important to check if the file opened successfully and close it after use using fclose(). The document provides an example program that reads names from a file, takes marks as input, and writes names and marks to an output file.
File Handling and Command Line Arguments in CMahendra Yadav
This document discusses file handling and command line arguments in C programming. It covers opening, reading and writing files, as well as the basics of passing arguments to a program from the command line using argc and argv. It includes examples of creating and writing to a file, as well as a program that adds command line arguments and outputs the sum.
This document discusses Java's input/output (I/O) capabilities through the java.io package. It describes the core I/O stream classes like InputStream, OutputStream, Reader and Writer. It also covers file I/O using File and FileInput/OutputStream classes. Buffered, filtered and character streams are explained. The use of serialization interfaces like Serializable and Externalizable for object I/O is summarized. The document provides examples of reading, writing and manipulating files and directories in Java.
The document discusses file input/output in C++. It covers the header file fstream.h, stream classes like ifstream and ofstream for file input/output, opening and closing files, reading/writing characters and objects to files, detecting end of file, moving file pointers for random access, and handling errors. Functions like open(), close(), get(), put(), read(), write(), seekg(), seekp(), tellg(), tellp(), eof(), fail(), bad(), good(), and clear() are described.
This document provides an overview of files and file handling in C programming. It discusses key concepts like defining and opening files, different modes for opening files, input/output functions like getc(), putc(), fscanf(), fprintf(), getw(), putw(), closing files, error handling, random access to files, and using command line arguments. Functions like fopen(), fclose(), feof(), ferror() are explained. Examples are given to demonstrate reading from and writing to files in text and binary formats.
The document discusses file handling in C++. It describes how programs can store data permanently in files on secondary storage devices. It explains the different stream classes like ifstream, ofstream and fstream that are used for file input, output and input/output operations. It provides details on the general steps to open, use and close files. It also discusses concepts like file pointers, reading and writing data to files, and updating records in sequential access files.
The document discusses various PHP functions for manipulating files including:
- readfile() which reads a file and writes it to the output buffer
- fopen() which opens files and gives more options than readfile()
- fread() which reads from an open file
- fclose() which closes an open file
- fgets() which reads a single line from a file
- feof() which checks if the end-of-file has been reached
It also discusses sanitizing user input before passing it to execution functions to prevent malicious commands from being run.
Files allow data to be permanently stored and accessed by programs. Basic file operations include opening, reading, writing, and closing files. To open a file, its name and access mode are passed to the fopen function, which returns a file pointer used for subsequent read/write operations. Characters can be read from and written to files using functions like getc and putc. Command line arguments passed when a program launches are accessible through the argc and argv parameters of the main function.
The document discusses file input/output (IO) in Java. It covers key concepts like streams, files, the File class, and IO classes. The File class represents file and directory pathnames and is used to get file information. Streams are used for IO and can be byte-based or character-based. The File class has methods for renaming, deleting, and getting attributes of files. Sample programs demonstrate using the File class to rename and delete files. The document also outlines the main abstract stream classes in Java for input, output, readers and writers.
File handling in C allows programs to perform operations on files stored on the local file system such as creation, opening, reading, writing and deletion of files. Common file handling functions include fopen() to open a file, fprintf() and fscanf() to write and read from files, fputc() and fgetc() to write and read single characters, and fclose() to close files. Binary files store data directly from memory to disk and allow for random access of records using functions like fseek(), ftell() and rewind(). Command line arguments can be accessed in the main() function through the argc and argv[] parameters.
The document discusses files and file operations in C/C++. It defines a file as a collection of bytes stored on a secondary storage device. There are different types of files like text files, data files, program files, and directory files. It describes opening, reading, writing, appending, and closing files using functions like fopen(), fread(), fwrite(), fclose(), etc. It also discusses random and sequential file access and modifying file contents using functions like fseek(), fread(), fwrite().
The document discusses file management in C. It defines a file as a collection of related data treated as a single unit by computers. C uses the FILE structure to store file attributes. The document outlines opening, reading, writing and closing files in C using functions like fopen(), fclose(), fread(), fwrite(), fseek(), ftell() and handling errors. It also discusses reading/writing characters using getc()/putc() and integers using getw()/putw() as well as formatted input/output with fscanf() and fprintf(). Random access to files using fseek() is also covered.
This document discusses file operations in C++. It defines what a file is and describes basic file operations like opening, writing, reading, and closing files. It explains how to set up a C++ program for file input/output by including the fstream header. Different stream objects like ifstream, ofstream, and fstream are used to represent input/output from files. The document also covers opening files, checking for open errors, writing and reading data from files using insertion and extraction operators, formatting file output, detecting the end of a file, and using getline() and put() functions for character I/O.
This document provides an overview of various file handling functions in C, including FILE structure, fopen(), fclose(), file access modes, fputs(), fgets(), fputc(), fgetc(), fprintf(), fscanf(), fwrite(), fread(), freopen(), fflush(), feof(), fseek(), ftell(), fgetpos(), fsetpos(), rewind(), perror(), and examples of how to use each function. It explains concepts like FILE pointer, size_t and fpos_t data types used for file handling.
The document discusses file handling in C++. It describes how to perform input/output operations on files using streams. There are three types of streams - input streams, output streams, and input/output streams. Key functions for file handling include open(), close(), get(), getline(), read(), write(), tellg(), tellp(), seekg(), seekp(), and eof(). An example program demonstrates how to add, view, search, delete, and update records in a binary file using file handling functions.
This document provides information about file operations in C programming. It discusses opening, reading from, writing to, and closing files using functions like fopen(), fread(), fwrite(), fclose(), getc(), putc(), fprintf(), fscanf(), getw(), and putw(). It gives the syntax and examples of using these functions to perform basic file input/output operations like reading and writing characters, integers, and strings to files. It also covers opening files in different modes, moving the file pointer, and checking for end of file.
This document discusses files in C language, including the basics of files, types of files, creating and reading/writing to files, and streams associated with files. It explains that a file is a collection of bytes stored on a disk that represents a sequence of data. There are two main types of files - binary and text. Binary files store raw data while text files store character data. The document outlines various functions for opening, closing, reading, and writing to files, as well as different modes for accessing files. It also discusses text and binary streams, which refer to the flow of data to and from files, and associated data types and flags in C.
This document discusses file management in C. It explains that files are used to store large amounts of data systematically so it can be accessed easily later. Files allow flexible storage and retrieval of data that is too large for memory. The key points covered include opening, reading, writing and closing files; using functions like fopen(), fclose(), fprintf(), fscanf(); handling errors; and dynamic memory allocation functions like malloc() and calloc().
This document discusses Java file input/output and streams. It covers the core stream classes like InputStream, OutputStream, Reader and Writer and their subclasses. File and FileInputStream/FileOutputStream allow working with files and directories on the file system. The key abstraction is streams, which are linked to physical devices and provide a way to send and receive data through classes that perform input or output of bytes or characters.
This document discusses data files in C programming. It defines a data file as a computer file that stores data for use by an application or system. It describes two types of data files: stream-oriented (text files and unformatted files) and system-oriented (low-level files). It explains how to open, read from, write to, and close data files using functions like fopen(), fclose(), getc(), putc(), fprintf(), and fscanf(). It provides examples of programs to create a data file by writing user input to a file and to read from an existing data file and display the contents.
This document discusses files and file operations in C programming. It covers opening, closing, reading from, and writing to files. Key points include:
- There are different modes for opening files, such as read ("r"), write ("w"), and append ("a").
- Common file functions include fopen() to open a file, fclose() to close it, fread() and fwrite() for reading and writing data, and fgetc() and fputc() for characters.
- Files can be accessed sequentially from the beginning or randomly by using functions like fseek() and ftell() to set and get the file position.
- Command line arguments allow passing parameters to a
The document discusses file handling in C++. It covers:
1) Using input/output files by opening, reading from, and writing to files using streams. Streams act as an interface between files and programs.
2) General file I/O steps which include declaring a file name variable, associating it with a disk file, opening the file, using it, and closing it.
3) Predefined console streams like cin, cout, cerr, and clog which are opened automatically and connected to the keyboard, display, and error output respectively.
This document discusses file handling in Python. It begins by explaining that files allow permanent storage of data, unlike standard input/output which is volatile. It then covers opening files in different modes, reading files line-by-line or as a whole, and modifying the file pointer position using seek(). Key points include opening files returns a file object, reading can be done line-by-line with for loops or using read()/readlines(), and seek() allows changing the file pointer location.
This document contains code snippets for opening, writing, reading, and closing files in C programming language. The snippets demonstrate opening files in read and write modes, getting input from the user and writing it to files, reading from files and printing the output, and checking for errors when opening files.
File input and output operations in Java are performed using streams. There are two types of streams - byte streams and character streams. Byte streams handle input/output at the byte level while character streams handle input/output at the character level using Unicode encoding. The File class in Java represents files and directories on the filesystem and provides methods to perform operations like creating, reading, updating and deleting files.
The document discusses input and output streams in Java. It provides an overview of character streams, byte streams, and connected streams. It explains how to read from and write to files using FileInputStream, FileOutputStream, FileReader, and FileWriter. It emphasizes the importance of specifying the correct character encoding when working with text files. An example demonstrates reading an image file as bytes, modifying some bytes, and writing the image to a new file.
The document discusses file handling in C++. It describes how programs can store data permanently in files on secondary storage devices. It explains the different stream classes like ifstream, ofstream and fstream that are used for file input, output and input/output operations. It provides details on the general steps to open, use and close files. It also discusses concepts like file pointers, reading and writing data to files, and updating records in sequential access files.
The document discusses various PHP functions for manipulating files including:
- readfile() which reads a file and writes it to the output buffer
- fopen() which opens files and gives more options than readfile()
- fread() which reads from an open file
- fclose() which closes an open file
- fgets() which reads a single line from a file
- feof() which checks if the end-of-file has been reached
It also discusses sanitizing user input before passing it to execution functions to prevent malicious commands from being run.
Files allow data to be permanently stored and accessed by programs. Basic file operations include opening, reading, writing, and closing files. To open a file, its name and access mode are passed to the fopen function, which returns a file pointer used for subsequent read/write operations. Characters can be read from and written to files using functions like getc and putc. Command line arguments passed when a program launches are accessible through the argc and argv parameters of the main function.
The document discusses file input/output (IO) in Java. It covers key concepts like streams, files, the File class, and IO classes. The File class represents file and directory pathnames and is used to get file information. Streams are used for IO and can be byte-based or character-based. The File class has methods for renaming, deleting, and getting attributes of files. Sample programs demonstrate using the File class to rename and delete files. The document also outlines the main abstract stream classes in Java for input, output, readers and writers.
File handling in C allows programs to perform operations on files stored on the local file system such as creation, opening, reading, writing and deletion of files. Common file handling functions include fopen() to open a file, fprintf() and fscanf() to write and read from files, fputc() and fgetc() to write and read single characters, and fclose() to close files. Binary files store data directly from memory to disk and allow for random access of records using functions like fseek(), ftell() and rewind(). Command line arguments can be accessed in the main() function through the argc and argv[] parameters.
The document discusses files and file operations in C/C++. It defines a file as a collection of bytes stored on a secondary storage device. There are different types of files like text files, data files, program files, and directory files. It describes opening, reading, writing, appending, and closing files using functions like fopen(), fread(), fwrite(), fclose(), etc. It also discusses random and sequential file access and modifying file contents using functions like fseek(), fread(), fwrite().
The document discusses file management in C. It defines a file as a collection of related data treated as a single unit by computers. C uses the FILE structure to store file attributes. The document outlines opening, reading, writing and closing files in C using functions like fopen(), fclose(), fread(), fwrite(), fseek(), ftell() and handling errors. It also discusses reading/writing characters using getc()/putc() and integers using getw()/putw() as well as formatted input/output with fscanf() and fprintf(). Random access to files using fseek() is also covered.
This document discusses file operations in C++. It defines what a file is and describes basic file operations like opening, writing, reading, and closing files. It explains how to set up a C++ program for file input/output by including the fstream header. Different stream objects like ifstream, ofstream, and fstream are used to represent input/output from files. The document also covers opening files, checking for open errors, writing and reading data from files using insertion and extraction operators, formatting file output, detecting the end of a file, and using getline() and put() functions for character I/O.
This document provides an overview of various file handling functions in C, including FILE structure, fopen(), fclose(), file access modes, fputs(), fgets(), fputc(), fgetc(), fprintf(), fscanf(), fwrite(), fread(), freopen(), fflush(), feof(), fseek(), ftell(), fgetpos(), fsetpos(), rewind(), perror(), and examples of how to use each function. It explains concepts like FILE pointer, size_t and fpos_t data types used for file handling.
The document discusses file handling in C++. It describes how to perform input/output operations on files using streams. There are three types of streams - input streams, output streams, and input/output streams. Key functions for file handling include open(), close(), get(), getline(), read(), write(), tellg(), tellp(), seekg(), seekp(), and eof(). An example program demonstrates how to add, view, search, delete, and update records in a binary file using file handling functions.
This document provides information about file operations in C programming. It discusses opening, reading from, writing to, and closing files using functions like fopen(), fread(), fwrite(), fclose(), getc(), putc(), fprintf(), fscanf(), getw(), and putw(). It gives the syntax and examples of using these functions to perform basic file input/output operations like reading and writing characters, integers, and strings to files. It also covers opening files in different modes, moving the file pointer, and checking for end of file.
This document discusses files in C language, including the basics of files, types of files, creating and reading/writing to files, and streams associated with files. It explains that a file is a collection of bytes stored on a disk that represents a sequence of data. There are two main types of files - binary and text. Binary files store raw data while text files store character data. The document outlines various functions for opening, closing, reading, and writing to files, as well as different modes for accessing files. It also discusses text and binary streams, which refer to the flow of data to and from files, and associated data types and flags in C.
This document discusses file management in C. It explains that files are used to store large amounts of data systematically so it can be accessed easily later. Files allow flexible storage and retrieval of data that is too large for memory. The key points covered include opening, reading, writing and closing files; using functions like fopen(), fclose(), fprintf(), fscanf(); handling errors; and dynamic memory allocation functions like malloc() and calloc().
This document discusses Java file input/output and streams. It covers the core stream classes like InputStream, OutputStream, Reader and Writer and their subclasses. File and FileInputStream/FileOutputStream allow working with files and directories on the file system. The key abstraction is streams, which are linked to physical devices and provide a way to send and receive data through classes that perform input or output of bytes or characters.
This document discusses data files in C programming. It defines a data file as a computer file that stores data for use by an application or system. It describes two types of data files: stream-oriented (text files and unformatted files) and system-oriented (low-level files). It explains how to open, read from, write to, and close data files using functions like fopen(), fclose(), getc(), putc(), fprintf(), and fscanf(). It provides examples of programs to create a data file by writing user input to a file and to read from an existing data file and display the contents.
This document discusses files and file operations in C programming. It covers opening, closing, reading from, and writing to files. Key points include:
- There are different modes for opening files, such as read ("r"), write ("w"), and append ("a").
- Common file functions include fopen() to open a file, fclose() to close it, fread() and fwrite() for reading and writing data, and fgetc() and fputc() for characters.
- Files can be accessed sequentially from the beginning or randomly by using functions like fseek() and ftell() to set and get the file position.
- Command line arguments allow passing parameters to a
The document discusses file handling in C++. It covers:
1) Using input/output files by opening, reading from, and writing to files using streams. Streams act as an interface between files and programs.
2) General file I/O steps which include declaring a file name variable, associating it with a disk file, opening the file, using it, and closing it.
3) Predefined console streams like cin, cout, cerr, and clog which are opened automatically and connected to the keyboard, display, and error output respectively.
This document discusses file handling in Python. It begins by explaining that files allow permanent storage of data, unlike standard input/output which is volatile. It then covers opening files in different modes, reading files line-by-line or as a whole, and modifying the file pointer position using seek(). Key points include opening files returns a file object, reading can be done line-by-line with for loops or using read()/readlines(), and seek() allows changing the file pointer location.
This document contains code snippets for opening, writing, reading, and closing files in C programming language. The snippets demonstrate opening files in read and write modes, getting input from the user and writing it to files, reading from files and printing the output, and checking for errors when opening files.
File input and output operations in Java are performed using streams. There are two types of streams - byte streams and character streams. Byte streams handle input/output at the byte level while character streams handle input/output at the character level using Unicode encoding. The File class in Java represents files and directories on the filesystem and provides methods to perform operations like creating, reading, updating and deleting files.
The document discusses input and output streams in Java. It provides an overview of character streams, byte streams, and connected streams. It explains how to read from and write to files using FileInputStream, FileOutputStream, FileReader, and FileWriter. It emphasizes the importance of specifying the correct character encoding when working with text files. An example demonstrates reading an image file as bytes, modifying some bytes, and writing the image to a new file.
This document provides an overview of Java input-output (I/O) streams and classes. It discusses the core stream classes like InputStream, OutputStream, Reader, Writer and their subclasses like FileInputStream, FileOutputStream, FileReader, FileWriter. It also covers buffered stream classes like BufferedInputStream, BufferedOutputStream, BufferedReader, BufferedWriter which provide better performance. Examples are given to demonstrate reading, writing and file handling using these stream classes.
The document discusses input/output files in Java. It covers the key classes used for reading and writing files in Java, including FileInputStream, FileOutputStream, FileReader, and FileWriter. It also discusses byte streams versus character streams, and provides examples of reading and writing to files in Java using these classes. Standard input/output streams like System.in and System.out are also covered.
File Handling Presentation As well as File handling code in java Update, Delete, Search, View, Insert in file code are available in this presentation in you face some issues so contact me 03244064060 , Also in my Email: [email protected] and Twitter @azeemaj101
This document provides information about input and output in Java. It discusses files, streams, standard streams like System.in and System.out, and different ways of handling keyboard input in Java programs. The File class in Java represents files and directories on the disk. It describes the various File class constructors, methods, and examples of using the File class to work with files like creating, reading, and checking files. Standard streams provide predefined paths for input/output. Streams can be byte-based or character-based. Keyboard input can be handled using command line arguments, the Console class, Scanner class, or InputStreamReader class.
Exceptions, I/O and Threads Input and Output in Java: The File Class, Standard Streams, Keyboard
Input, File I/O Using Byte Streams, Character Streams, File I/O Using Character Streams -
Buffered Streams, File I/O Using a Buffered Stream, Keyboard Input Using a Buffered Stream,Writing Text Files. Threads: Threads vs. Processes, Creating Threads by Extending Thread,
Creating Threads by Implementing Runnable, Advantages of Using Threads, Daemon Threads,
Thread States, Thread Problems, Synchronization. Exceptions: Exception Handling, The Exception
Hierarchy, throws statement, throw statement, Developing user defined Exception Classes- The
finally Block.
The document discusses file handling in Java. It covers:
1) The System class contains standard input, output, and error streams for file I/O.
2) Files allow storing data permanently even after a program terminates. Java uses file streams for input and output between memory and disk files.
3) Files can be text or binary. Text files can be read by editors while binary files contain internal data representations. Objects can also be written to files.
In this tutorial, I take you through an important feature of Java: File Operations. We are going to take a look at Character and Byte Streams, some built-in Classes and their functionalities to be able to perform file operations. Then we are going to learn about a famous concept called exception handling. We are going to finalize this tutorial with Number Formatting.
Check out rest of the Tutorials: https://berksoysal.blogspot.com/2016/06/java-se-tutorials-basics-exercises.html
This document provides an overview of input/output operations in Java using the java.io package. It discusses streams and channels, file I/O, reading and writing files, serialization, and the Observer and Observable interfaces. The key classes covered include File, PrintWriter, Scanner, InputStream, OutputStream, Reader, Writer, Buffer, Channel, and classes for serialization. Examples are provided for reading and writing files using byte streams, character streams, buffers, and channels.
This document provides an introduction to file handling in Java. It discusses how file handling allows programs to permanently store output data by writing it to files on secondary storage devices like hard disks. It covers key concepts like input and output streams that represent the flow of data into and out of a program. It also discusses how to create, write to, read from, and delete files in Java using classes like File, FileWriter, FileReader and Scanner. Common file methods like getName(), getAbsolutePath(), exists() are also outlined.
Core Java Programming Language (JSE) : Chapter XI - Console I/O and File I/OWebStackAcademy
This document discusses console and file input/output in Java. It describes how to read from standard input using System.in, write to standard output using System.out, and read/write files using File and FileReader/FileWriter classes. Methods for formatted output/input are also covered. The document provides examples for reading keyboard input, writing to console, and reading/writing files line-by-line.
This document provides information on input/output operations, file handling, and serialization in Java. It discusses Java's input and output streams for reading and writing bytes and characters. It describes classes for working with files like File, FileInputStream, FileOutputStream, FileReader, and FileWriter. Examples are given for reading from and writing to files and the console. The document also introduces serialization in Java for converting objects to byte streams for storage or transmission.
The document discusses Java's stream-based input/output capabilities provided by the java.io package. It describes the different types of streams like input streams, output streams, binary streams, character streams. It covers classes like InputStream, OutputStream, DataInputStream, DataOutputStream and how to read from and write to files using FileInputStream and FileOutputStream. It also discusses formatting output, accessing files and directories, and filtering stream content.
The document discusses files, streams, and different classes in Java for reading and writing files and streams. It explains that files exist on a local file system while streams represent a flow of characters. It also discusses the process of opening, reading from, and closing files, as well as using classes like FileReader, FileWriter, FileInputStream and FileOutputStream for reading/writing characters and bytes. It recommends using BufferedReader and BufferedWriter for more efficient reading of lines and writing of strings.
This document provides an overview of streams and file input/output (I/O) in Java. It discusses the differences between text and binary files, and how to read from and write to both types of files using classes like PrintWriter, FileOutputStream, BufferedReader, and FileReader. Key points covered include opening and closing files, reading/writing text with print/println methods, and handling I/O exceptions. The goal is to learn the basic concepts and mechanisms for saving and loading data from files.
The servlet creates a table displaying the values of standard CGI variables for the current HTTP request. It stores the CGI variable names and corresponding servlet methods to access their values in a 2D string array. It iterates through the array, outputting the name and value of each variable to generate an HTML table showing all the CGI variables and their values for the request. This allows developers familiar with CGI programming to see how servlets access equivalent information from HTTP requests.
This document provides an introduction and overview of PHP (Hypertext Preprocessor), a popular scripting language for web development. It discusses downloading and installing PHP, provides a basic PHP tutorial, and lists IDE tools and tags utilities for PHP development. It also covers debugging PHP, limitations of PHP, and includes several appendices with PHP code examples.
This tutorial provides instructions for creating an animated owl clock in Flash over 4 hours. It involves drawing various shapes to create the owl's head, body, base, eyes and beak. These shapes are then converted to symbols and layered. Additional steps include adding gradients, outlining shapes, and creating a movie clip to make the eyes blink by moving back and forth. Precise dimensions, coordinates, fills and other properties are set at each step to assemble the final owl clock graphic.
This document provides an introduction to TCP/IP networking. It discusses the basics of IP addressing and subnet masking. It describes common TCP/IP utilities like Ping and Traceroute used to diagnose network issues. It also covers topics like ports and services, firewalls, DHCP, and the assignment of IP addresses.
This document discusses creating network clients in Java. It covers creating sockets, implementing a generic network client, parsing data with StringTokenizer, retrieving files from HTTP servers and documents using URL class. It provides code for a generic network client, parsing strings with StringTokenizer, an address verifier client, and classes to retrieve URIs and URLs. It also briefly discusses talking to servers interactively and using the URL class to write a basic web browser.
This document provides an introduction and tutorial on Java Server Pages (JSP) technology. It explains that JSP files allow for server-side dynamic web development using Java code embedded in HTML pages. It covers JSP concepts, compares JSP to ASP and servlets, describes the JSP architecture and processing, and provides instructions for setting up a JSP development environment.
The document provides an overview of building server-side Java web applications using Tomcat, JSP, and JavaBeans, covering topics like installing Tomcat, creating Java and JSP projects, writing JSP pages and JavaBeans, using sessions and includes, and the Model 2 architecture. It includes tutorials on setting up a sample "Phones" application to demonstrate concepts like retrieving data from a database and displaying it dynamically in JSP pages.
The document discusses JavaServer Pages (JSP) scripting elements. It describes the three types of JSP constructs that can be embedded in a page: scripting elements, directives, and actions. Scripting elements allow Java code to be specified that will become part of the resultant servlet. Expressions, scriptlets, and declarations are the three forms of scripting elements. Expressions insert dynamic values directly into the output page, scriptlets insert Java code into the servlet's service method, and declarations add methods and fields to the servlet class. The document provides an example of a simple JSP page that uses expressions.
This document provides an overview of using JavaScript to add dynamic content and interactivity to web pages. It covers generating HTML dynamically with document.write(), monitoring user events with event handlers like onclick, the basic syntax of JavaScript including dynamic typing, functions, objects, and arrays. It also gives examples of applications like determining browser window size, modifying images dynamically, and highlighting images as the mouse moves over them.
This document provides an introduction to and instructions for completing a Flash MX tutorial. The tutorial guides the user through creating an animated movie about a car, including defining document properties, creating vector art, adding animation and sounds, and publishing the final movie. Completing the tutorial teaches basic Flash skills and takes approximately three hours. It analyzes a completed Flash movie file as an example and provides step-by-step directions for each section of the tutorial.
This document provides an overview of cascading style sheets (CSS) and how they can be used to control the formatting and layout of HTML elements. It discusses specifying style rules, using external and inline style sheets, creating custom elements with style classes, and properties for controlling fonts, text, backgrounds, and more. Precedence rules and browser support for different CSS levels are also covered. Examples are provided to demonstrate how CSS can be applied to style HTML documents.
The document discusses three ways to include external content in JSP documents:
1) The include directive includes files at translation time, allowing included files to contain JSP code. However, the including page must be updated when included files change.
2) The jsp:include action includes files at request time, avoiding the need to update the including page. Included files cannot contain JSP code.
3) The jsp:plugin element embeds applets using the Java Plug-In, but applets are limited to JDK 1.1 or earlier due to browser limitations.
Frames allow dividing an HTML page into multiple sections or cells. A frameset defines rows and columns to divide the browser window. Individual frames are populated by specifying the SRC attribute. Frames can be nested to create complex layouts. The TARGET attribute is used to load content into a specific named frame. While frames provide layout benefits, they also have disadvantages like confusing the back button and making content difficult to bookmark.
This document provides instructions for customizing a SorBose Flash template by opening the FLA file, changing text and images, adding links, and publishing the modified Flash file. Key steps include opening the FLA file in Flash, locating elements in the timeline or symbols panel to edit text, images, and buttons. Links can be added to buttons using action script code. The final customized Flash file is published and replaced in the template files.
Content and eLearning Standards: Finding the Best Fit for Your-TrainingRustici Software
Tammy Rutherford, Managing Director of Rustici Software, walks through the pros and cons of different standards to better understand which standard is best for your content and chosen technologies.
UiPath Community Berlin: Studio Tips & Tricks and UiPath InsightsUiPathCommunity
Join the UiPath Community Berlin (Virtual) meetup on May 27 to discover handy Studio Tips & Tricks and get introduced to UiPath Insights. Learn how to boost your development workflow, improve efficiency, and gain visibility into your automation performance.
📕 Agenda:
- Welcome & Introductions
- UiPath Studio Tips & Tricks for Efficient Development
- Best Practices for Workflow Design
- Introduction to UiPath Insights
- Creating Dashboards & Tracking KPIs (Demo)
- Q&A and Open Discussion
Perfect for developers, analysts, and automation enthusiasts!
This session streamed live on May 27, 18:00 CET.
Check out all our upcoming UiPath Community sessions at:
👉 https://community.uipath.com/events/
Join our UiPath Community Berlin chapter:
👉 https://community.uipath.com/berlin/
AI in Java - MCP in Action, Langchain4J-CDI, SmallRye-LLM, Spring AIBuhake Sindi
This is the presentation I gave with regards to AI in Java, and the work that I have been working on. I've showcased Model Context Protocol (MCP) in Java, creating server-side MCP server in Java. I've also introduced Langchain4J-CDI, previously known as SmallRye-LLM, a CDI managed too to inject AI services in enterprise Java applications. Also, honourable mention: Spring AI.
Introducing FME Realize: A New Era of Spatial Computing and ARSafe Software
A new era for the FME Platform has arrived – and it’s taking data into the real world.
Meet FME Realize: marking a new chapter in how organizations connect digital information with the physical environment around them. With the addition of FME Realize, FME has evolved into an All-data, Any-AI Spatial Computing Platform.
FME Realize brings spatial computing, augmented reality (AR), and the full power of FME to mobile teams: making it easy to visualize, interact with, and update data right in the field. From infrastructure management to asset inspections, you can put any data into real-world context, instantly.
Join us to discover how spatial computing, powered by FME, enables digital twins, AI-driven insights, and real-time field interactions: all through an intuitive no-code experience.
In this one-hour webinar, you’ll:
-Explore what FME Realize includes and how it fits into the FME Platform
-Learn how to deliver real-time AR experiences, fast
-See how FME enables live, contextual interactions with enterprise data across systems
-See demos, including ones you can try yourself
-Get tutorials and downloadable resources to help you start right away
Whether you’re exploring spatial computing for the first time or looking to scale AR across your organization, this session will give you the tools and insights to get started with confidence.
Droidal: AI Agents Revolutionizing HealthcareDroidal LLC
Droidal’s AI Agents are transforming healthcare by bringing intelligence, speed, and efficiency to key areas such as Revenue Cycle Management (RCM), clinical operations, and patient engagement. Built specifically for the needs of U.S. hospitals and clinics, Droidal's solutions are designed to improve outcomes and reduce administrative burden.
Through simple visuals and clear examples, the presentation explains how AI Agents can support medical coding, streamline claims processing, manage denials, ensure compliance, and enhance communication between providers and patients. By integrating seamlessly with existing systems, these agents act as digital coworkers that deliver faster reimbursements, reduce errors, and enable teams to focus more on patient care.
Droidal's AI technology is more than just automation — it's a shift toward intelligent healthcare operations that are scalable, secure, and cost-effective. The presentation also offers insights into future developments in AI-driven healthcare, including how continuous learning and agent autonomy will redefine daily workflows.
Whether you're a healthcare administrator, a tech leader, or a provider looking for smarter solutions, this presentation offers a compelling overview of how Droidal’s AI Agents can help your organization achieve operational excellence and better patient outcomes.
A free demo trial is available for those interested in experiencing Droidal’s AI Agents firsthand. Our team will walk you through a live demo tailored to your specific workflows, helping you understand the immediate value and long-term impact of adopting AI in your healthcare environment.
To request a free trial or learn more:
https://droidal.com/
SAP Sapphire 2025 ERP1612 Enhancing User Experience with SAP Fiori and AIPeter Spielvogel
Explore how AI in SAP Fiori apps enhances productivity and collaboration. Learn best practices for SAPUI5, Fiori elements, and tools to build enterprise-grade apps efficiently. Discover practical tips to deploy apps quickly, leveraging AI, and bring your questions for a deep dive into innovative solutions.
Introducing the OSA 3200 SP and OSA 3250 ePRCAdtran
Adtran's latest Oscilloquartz solutions make optical pumping cesium timing more accessible than ever. Discover how the new OSA 3200 SP and OSA 3250 ePRC deliver superior stability, simplified deployment and lower total cost of ownership. Built on a shared platform and engineered for scalable, future-ready networks, these models are ideal for telecom, defense, metrology and more.
Dev Dives: System-to-system integration with UiPath API WorkflowsUiPathCommunity
Join the next Dev Dives webinar on May 29 for a first contact with UiPath API Workflows, a powerful tool purpose-fit for API integration and data manipulation!
This session will guide you through the technical aspects of automating communication between applications, systems and data sources using API workflows.
📕 We'll delve into:
- How this feature delivers API integration as a first-party concept of the UiPath Platform.
- How to design, implement, and debug API workflows to integrate with your existing systems seamlessly and securely.
- How to optimize your API integrations with runtime built for speed and scalability.
This session is ideal for developers looking to solve API integration use cases with the power of the UiPath Platform.
👨🏫 Speakers:
Gunter De Souter, Sr. Director, Product Manager @UiPath
Ramsay Grove, Product Manager @UiPath
This session streamed live on May 29, 2025, 16:00 CET.
Check out all our upcoming UiPath Dev Dives sessions:
👉 https://community.uipath.com/dev-dives-automation-developer-2025/
As data privacy regulations become more pervasive across the globe and organizations increasingly handle and transfer (including across borders) meaningful volumes of personal and confidential information, the need for robust contracts to be in place is more important than ever.
This webinar will provide a deep dive into privacy contracting, covering essential terms and concepts, negotiation strategies, and key practices for managing data privacy risks.
Whether you're in legal, privacy, security, compliance, GRC, procurement, or otherwise, this session will include actionable insights and practical strategies to help you enhance your agreements, reduce risk, and enable your business to move fast while protecting itself.
This webinar will review key aspects and considerations in privacy contracting, including:
- Data processing addenda, cross-border transfer terms including EU Model Clauses/Standard Contractual Clauses, etc.
- Certain legally-required provisions (as well as how to ensure compliance with those provisions)
- Negotiation tactics and common issues
- Recent lessons from recent regulatory actions and disputes
Marko.js - Unsung Hero of Scalable Web Frameworks (DevDays 2025)Eugene Fidelin
Marko.js is an open-source JavaScript framework created by eBay back in 2014. It offers super-efficient server-side rendering, making it ideal for big e-commerce sites and other multi-page apps where speed and SEO really matter. After over 10 years of development, Marko has some standout features that make it an interesting choice. In this talk, I’ll dive into these unique features and showcase some of Marko's innovative solutions. You might not use Marko.js at your company, but there’s still a lot you can learn from it to bring to your next project.
Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025Nikki Chapple
Session | Protecting Your Sensitive Data with Microsoft Purview: Practical Information Protection and DLP Strategies
Presenter | Nikki Chapple (MVP| Principal Cloud Architect CloudWay) & Ryan John Murphy (Microsoft)
Event | IRMS Conference 2025
Format | Birmingham UK
Date | 18-20 May 2025
In this closing keynote session from the IRMS Conference 2025, Nikki Chapple and Ryan John Murphy deliver a compelling and practical guide to data protection, compliance, and information governance using Microsoft Purview. As organizations generate over 2 billion pieces of content daily in Microsoft 365, the need for robust data classification, sensitivity labeling, and Data Loss Prevention (DLP) has never been more urgent.
This session addresses the growing challenge of managing unstructured data, with 73% of sensitive content remaining undiscovered and unclassified. Using a mountaineering metaphor, the speakers introduce the “Secure by Default” blueprint—a four-phase maturity model designed to help organizations scale their data security journey with confidence, clarity, and control.
🔐 Key Topics and Microsoft 365 Security Features Covered:
Microsoft Purview Information Protection and DLP
Sensitivity labels, auto-labeling, and adaptive protection
Data discovery, classification, and content labeling
DLP for both labeled and unlabeled content
SharePoint Advanced Management for workspace governance
Microsoft 365 compliance center best practices
Real-world case study: reducing 42 sensitivity labels to 4 parent labels
Empowering users through training, change management, and adoption strategies
🧭 The Secure by Default Path – Microsoft Purview Maturity Model:
Foundational – Apply default sensitivity labels at content creation; train users to manage exceptions; implement DLP for labeled content.
Managed – Focus on crown jewel data; use client-side auto-labeling; apply DLP to unlabeled content; enable adaptive protection.
Optimized – Auto-label historical content; simulate and test policies; use advanced classifiers to identify sensitive data at scale.
Strategic – Conduct operational reviews; identify new labeling scenarios; implement workspace governance using SharePoint Advanced Management.
🎒 Top Takeaways for Information Management Professionals:
Start secure. Stay protected. Expand with purpose.
Simplify your sensitivity label taxonomy for better adoption.
Train your users—they are your first line of defense.
Don’t wait for perfection—start small and iterate fast.
Align your data protection strategy with business goals and regulatory requirements.
💡 Who Should Watch This Presentation?
This session is ideal for compliance officers, IT administrators, records managers, data protection officers (DPOs), security architects, and Microsoft 365 governance leads. Whether you're in the public sector, financial services, healthcare, or education.
🔗 Read the blog: https://nikkichapple.com/irms-conference-2025/
Fully Open-Source Private Clouds: Freedom, Security, and ControlShapeBlue
In this presentation, Swen Brüseke introduced proIO's strategy for 100% open-source driven private clouds. proIO leverage the proven technologies of CloudStack and LINBIT, complemented by professional maintenance contracts, to provide you with a secure, flexible, and high-performance IT infrastructure. He highlighted the advantages of private clouds compared to public cloud offerings and explain why CloudStack is in many cases a superior solution to Proxmox.
--
The CloudStack European User Group 2025 took place on May 8th in Vienna, Austria. The event once again brought together open-source cloud professionals, contributors, developers, and users for a day of deep technical insights, knowledge sharing, and community connection.
For those who have ever wanted to recreate classic games, this presentation covers my five-year journey to build a NES emulator in Kotlin. Starting from scratch in 2020 (you can probably guess why), I’ll share the challenges posed by the architecture of old hardware, performance optimization (surprise, surprise), and the difficulties of emulating sound. I’ll also highlight which Kotlin features shine (and why concurrency isn’t one of them). This high-level overview will walk through each step of the process—from reading ROM formats to where GPT can help, though it won’t write the code for us just yet. We’ll wrap up by launching Mario on the emulator (hopefully without a call from Nintendo).
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification o...Ivan Ruchkin
A poster presented by Thomas Waite and Radoslav Ivanov at the 2nd International Conference on Neuro-symbolic Systems (NeuS) in May 2025.
Paper: https://arxiv.org/abs/2502.21308
Abstract: It remains a challenge to provide safety guarantees for autonomous systems with neural perception and control. A typical approach obtains symbolic bounds on perception error (e.g., using conformal prediction) and performs verification under these bounds. However, these bounds can lead to drastic conservatism in the resulting end-to-end safety guarantee. This paper proposes an approach to synthesize symbolic perception error bounds that serve as an optimal interface between perception performance and control verification. The key idea is to consider our error bounds to be heteroskedastic with respect to the system's state -- not time like in previous approaches. These bounds can be obtained with two gradient-free optimization algorithms. We demonstrate that our bounds lead to tighter safety guarantees than the state-of-the-art in a case study on a mountain car.
What’s New in Web3 Development Trends to Watch in 2025.pptxLisa ward
Emerging Web3 development trends in 2025 include AI integration, enhanced scalability, decentralized identity, and increased enterprise adoption of blockchain technologies.
New Ways to Reduce Database Costs with ScyllaDBScyllaDB
How ScyllaDB’s latest capabilities can reduce your infrastructure costs
ScyllaDB has been obsessed with price-performance from day 1. Our core database is architected with low-level engineering optimizations that squeeze every ounce of power from the underlying infrastructure. And we just completed a multi-year effort to introduce a set of new capabilities for additional savings.
Join this webinar to learn about these new capabilities: the underlying challenges we wanted to address, the workloads that will benefit most from each, and how to get started. We’ll cover ways to:
- Avoid overprovisioning with “just-in-time” scaling
- Safely operate at up to ~90% storage utilization
- Cut network costs with new compression strategies and file-based streaming
We’ll also highlight a “hidden gem” capability that lets you safely balance multiple workloads in a single cluster. To conclude, we will share the efficiency-focused capabilities on our short-term and long-term roadmaps.
2. Input/Output2 www.corewebprogramming.com
Agenda
• Handling files and directories through the
File class
• Understanding which streams to use for
character-based or byte-based streams
• Character File input and output
• Formatting output
• Reading data from the console
• Binary File input and output
3. Input/Output3 www.corewebprogramming.com
File Class
• A File object can refer to either a file or a
directory
File file1 = new File("data.txt");
File file1 = new File("C:java");
– To obtain the path to the current working directory use
System.getProperty("user.dir");
– To obtain the file or path separator use
System.getProperty("file.separator");
System.getProperty("path.separator");
or
File.separator()
File.pathSeparator()
4. Input/Output4 www.corewebprogramming.com
Useful File Methods
• isFile/isDirectory
• canRead/canWrite
• length
– Length of the file in bytes (long) or 0 if nonexistant
• list
– If the File object is a directory, returns a String array of all the
files and directories contained in the directory; otherwise, null
• mkdir
– Creates a new subdirectory
• delete
– Deletes the directory and returns true if successful
• toURL
– Converts the file path to a URL object
5. Input/Output5 www.corewebprogramming.com
Directory Listing, Example
import java.io.*;
public class DirListing {
public static void main(String[] args) {
File dir = new File(System.getProperty("user.dir"));
if(dir.isDirectory()){
System.out.println("Directory of " + dir);
String[] listing = dir.list();
for(int i=0; i<listing.length; i++) {
System.out.println("t" + listing[i]);
}
}
}
}
7. Input/Output7 www.corewebprogramming.com
Input/Output
• The java.io package provides over 60
input/output classes (streams)
• Streams are combined (piped together) to
create a desired data source or sink
• Streams are either byte-oriented or
character-oriented
– Use DataStreams for byte-oriented I/O
– Use Readers and Writers for character-based I/O
• Character I/O uses an encoding scheme
• Note: An IOException may occur during
any I/O operation
8. Input/Output8 www.corewebprogramming.com
Character File Output
Desired … Methods Construction
Character File Ouput FileWriter File file = new File("filename");
write(int char) FileWriter fout = new FileWriter(file);
write(byte[] buffer) or
write(String str) FileWriter fout = new FileWriter("filename");
Buffered Character BufferedWriter File file = new File("filename");
File Output write(int char) FileWriter fout = new FileWriter(file);
write(char[] buffer) BufferedWriter bout = new BufferedWriter(fout);
write(String str) or
newLine() BufferedWriter bout = new BufferedWriter(
new FileWriter(
new File("filename")));
9. Input/Output9 www.corewebprogramming.com
Character File Output, cont.
Desired … Methods Construction
Character Output PrintWriter FileWriter fout = new FileWriter("filename");
write(int char) PrintWriter pout = new PrintWriter(fout);
write(char[] buffer) or
writer(String str) PrintWriter pout = new PrintWriter(
print( … ) new FileWriter("filename"));
println( … ) or
PrintWriter pout = new PrintWriter(
new BufferedWriter(
new FileWriter("filename")));
10. Input/Output10 www.corewebprogramming.com
FileWriter
• Constructors
– FileWriter(String filename)/FileWriter(File file)
• Creates a output stream using the default encoding
– FileWriter(String filename, boolean append)
• Creates a new output stream or appends to the existing output
stream (append = true)
• Useful Methods
– write(String str)/write(char[] buffer)
• Writes string or array of chars to the file
– write(int char)
• Writes a character (int) to the file
– flush
• Writes any buffered characters to the file
– close
• Closes the file stream after performing a flush
– getEncoding
• Returns the character encoding used by the file stream
11. Input/Output11 www.corewebprogramming.com
CharacterFileOutput, Example
import java.io.*;
public class CharacterFileOutput {
public static void main(String[] args) {
FileWriter out = null;
try {
out = new FileWriter("book.txt");
System.out.println("Encoding: " + out.getEncoding());
out.write("Core Web Programming");
out.close();
out = null;
} catch(IOException ioe) {
System.out.println("IO problem: " + ioe);
ioe.printStackTrace();
try {
if (out != null) {
out.close();
}
} catch(IOException ioe2) { }
}
}
}
12. Input/Output12 www.corewebprogramming.com
CharacterFileOutput, Result
> java CharacterFileOutput
Encoding: Cp1252
> type book.txt
Core Web Programming
• Note: Cp1252 is Windows Western Europe / Latin-1
– To change the system default encoding use
System.setProperty("file.encoding", "encoding");
– To specify the encoding when creating the output steam, use an
OutputStreamWriter
OutputStreamWriter out =
new OutputStreamWriter(
new FileOutputStream("book.txt", "8859_1"));
13. Input/Output13 www.corewebprogramming.com
Formatting Output
• Use DecimalFormat to control spacing
and formatting
– Java has no printf method
• Approach
1. Create a DecimalFormat object describing the
formatting
DecimalFormat formatter =
new DecimalFormat("#,###.##");
2. Then use the format method to convert values into
formatted strings
formatter.format(24.99);
14. Input/Output14 www.corewebprogramming.com
Formatting Characters
Symbol Meaning
0 Placeholder for a digit.
# Placeholder for a digit.
If the digit is leading or trailing zero, then don't display.
. Location of decimal point.
, Display comma at this location.
- Minus sign.
E Scientific notation.
Indicates the location to separate the mattissa from the exponent.
% Multipy the value by 100 and display as a percent.
15. Input/Output15 www.corewebprogramming.com
NumFormat, Example
import java.text.*;
public class NumFormat {
public static void main (String[] args) {
DecimalFormat science = new DecimalFormat("0.000E0");
DecimalFormat plain = new DecimalFormat("0.0000");
for(double d=100.0; d<140.0; d*=1.10) {
System.out.println("Scientific: " + science.format(d) +
" and Plain: " + plain.format(d));
}
}
}
17. Input/Output17 www.corewebprogramming.com
Character File Input
Desired … Methods Construction
Character File Input FileReader File file = new File("filename");
read() FileReader fin = new FileReader(file);
read(char[] buffer) or
FileReader fin = new FileReader("filename");
Buffered Character BufferedReader File file = new File("filename");
File Input read() FileReader fin = new FileReader(file);
read(char[] buffer) BufferedReader bin = new BufferedReader(fin);
readLine() or
BufferedReader bin = new BufferedReader(
new FileReader(
new File("filename")));
18. Input/Output18 www.corewebprogramming.com
FileReader
• Constructors
– FileReader(String filename)/FileReader(File file)
• Creates a input stream using the default encoding
• Useful Methods
– read/read(char[] buffer)
• Reads a single character or array of characters
• Returns –1 if the end of the steam is reached
– reset
• Moves to beginning of stream (file)
– skip
• Advances the number of characters
• Note: Wrap a BufferedReader around the FileReader to
read full lines of text using readLine
19. Input/Output19 www.corewebprogramming.com
CharacterFileInput, Example
import java.io.*;
public class CharacterFileInput {
public static void main(String[] args) {
File file = new File("book.txt");
FileReader in = null;
if(file.exists()) {
try {
in = new FileReader(file);
System.out.println("Encoding: " + in.getEncoding());
char[] buffer = new char[(int)file.length()];
in.read(buffer);
System.out.println(buffer);
in.close();
} catch(IOException ioe) {
System.out.println("IO problem: " + ioe);
ioe.printStackTrace();
...
}
}
}
}
20. Input/Output20 www.corewebprogramming.com
CharacterFileInput, Result
> java CharacterFileInput
Encoding: Cp1252
Core Web Programming
• Alternatively, could read file one line at a time:
BufferedReader in =
new BufferedReader(new FileReader(file));
String lineIn;
while ((lineIn = in.readLine()) != null) {
System.out.println(lineIn);
}
21. Input/Output21 www.corewebprogramming.com
Console Input
• To read input from the console, a stream
must be associated with the standard input,
System.in
import java.io.*;
public class IOInput{
public static void main(String[] args) {
BufferedReader keyboard;
String line;
try {
System.out.print("Enter value: ");
System.out.flush();
keyboard = new BufferedReader(
new InputStreamReader(System.in));
line = keyboard.readLine();
} catch(IOException e) {
System.out.println("Error reading input!"); }
}
}
}
22. Input/Output22 www.corewebprogramming.com
Binary File Input and Output
• Handle byte-based I/O using a
DataInputStream or DataOutputStream
– The readFully method blocks until all bytes are read or an EOF occurs
– Values are written in big-endian fashion regardless of computer platform
DataType DataInputStream DataOutputStream
byte readByte writeByte
short readShort writeShort
int readInt writeInt
long readLong writeLong
float readFloat writeFloat
double readDouble writeDouble
boolean readBoolean writeBoolean
char readChar writeChar
String readUTF writeUTF
byte[] readFully
23. Input/Output23 www.corewebprogramming.com
UCS Transformation Format –
UTF-8
• UTF encoding represents a 2-byte Unicode
character in 1-3 bytes
– Benefit of backward compatibility with existing ASCII
data (one-byte over two-byte Unicode)
– Disadvantage of different byte sizes for character
representation
UTF Encoding
Bit Pattern Representation
0xxxxxxx ASCII (0x0000 - 0x007F)
10xxxxxx Second or third byte
110xxxxx First byte in a 2-byte sequence (0x0080 - 0x07FF)
1110xxxx First byte in a 3-byte sequence (0x0800 - 0xFFFF)
24. Input/Output24 www.corewebprogramming.com
Binary File Output
Desired … Methods Construction
Binary File Output FileOutputStream File file = new File("filename");
bytes write(byte) FileOutputStream fout = new FileOutputStream(file);
write(byte[] buffer) or
FileOutputStream fout = new FileOutputStream("filename");
Binary File Output DataOutputStream File file = new File("filename");
byte writeByte(byte) FileOutputStream fout = new FileOutputStream(file);
short writeShort(short) DataOutputStream dout = new DataOutputStream(fout);
int writeInt(int)
long writeLong(long) or
float writeFloat(float)
double writeDouble(double) DataOutputStream dout = new DataOutputStream(
char writechar(char) new FileOutputStream(
boolean writeBoolean(boolean) new File("filename")));
writeUTF(string)
writeBytes(string)
writeChars(string)
25. Input/Output25 www.corewebprogramming.com
Binary File Output, cont.
Desired … Methods Construction
Buffered Binary BufferedOutputStream File file = new File("filename");
File Output flush() FileOutputStream fout = new FileOutputStream(file);
write(byte) BufferedOutputStream bout = new BufferedOutputStream(fout);
write(byte[] buffer, int off, int len) DataOutputStream dout = new DataOutputStream(bout);
or
DataOutputStream dout = new DataOutputStream(
new BufferedOutputStream(
new FileOutputStream(
new File("filename"))));
26. Input/Output26 www.corewebprogramming.com
BinaryFileOutput, Example
import java.io.*;
public class BinaryFileOutput {
public static void main(String[] args) {
int[] primes = { 1, 2, 3, 5, 11, 17, 19, 23 };
DataOutputStream out = null;
try {
out = new DataOutputStream(
new FileOutputStream("primes.bin"));
for(int i=0; i<primes.length; i++) {
out.writeInt(primes[i]);
}
out.close();
} catch(IOException ioe) {
System.out.println("IO problem: " + ioe);
ioe.printStackTrace();
}
}
}
27. Input/Output27 www.corewebprogramming.com
Binary File Input
Desired … Methods Construction
Binary File Input FileInputStream File file = new File("filename");
bytes read() FileInputStream fin = new FileInputStream(file);
read(byte[] buffer) or
FileInputStream fin = new FileInputStream("filename");
Binary File Input DataInputStream File file = new File("filename");
byte readByte() FileInputStream fin = new FileInputStream(file);
short readShort() DataInputStream din = new DataInputStream(fin);
int readInt()
long readLong() or
float readFloat()
double readDouble() DataInputStream din = new DataInputStream(
char readchar() new FileInputStream(
boolean readBoolean() new File("filename")));
readUTF()
readFully(byte[] buffer)
28. Input/Output28 www.corewebprogramming.com
Binary File Input, cont.
Desired … Methods Construction
Bufferred Binary BufferedInputStream File file = new File("filename");
File Input read() FileInputStream fin = new FileInputStream(file);
read(byte[] buffer, int off, int len) BufferedInputStream bin = new BufferedInputStream(fin);
skip(long) DataInputStream din = new DataInputStream(bin);
or
DataInputStream din = new DataInputStream(
new BufferedInputStream(
new FileInputStream(
new File("filename"))));
29. Input/Output29 www.corewebprogramming.com
BinaryFileInput, Example
import java.io.*;
public class BinaryFileInput {
public static void main(String[] args) {
DataInputStream in = null;
File file = new File("primes.bin");
try {
in = new DataInputStream(
new FileInputStream(file));
int prime;
long size = file.length()/4; // 4 bytes per int
for(long i=0; i<size; i++) {
prime = in.readInt();
System.out.println(prime);
}
in.close();
} catch(IOException ioe) {
System.out.println("IO problem: " + ioe);
ioe.printStackTrace();
}
}
}
30. Input/Output30 www.corewebprogramming.com
Summary
• A File can refer to either a file or a
directory
• Use Readers and Writers for character-
based I/O
– A BufferedReader is required for readLine
– Java provides no printf; use DecimalFormat for formatted
output
• Use DataStreams for byte-based I/O
– Chain a FileOutputStream to a DataOutputStream for
binary file output
– Chain a FileInputStream to a DataInputStream for binary
file input