1 Read and write files
"Experimental Purpose"
(1) Master the reading and writing method of the text file.
(2) Master the method of reading and writing random files.
(3) Master the basic use of InputStreamandoutputstream abstract class.
(4) Mastering fileinputstream,fileoutputstream,datainputstream, DataOutputStream The basic use of abstract classes.
"Experimental Requirements"
Requirements One: Establish the Streamdemo class, to achieve the establishment of a standard input and output stream, can read the string from the keyboard and output the string.
Requirement Two: Apply Java input and output stream, processing a picture file: Write a few characters " by Michael" On the picture, add the name to the picture to identify "I process the picture", then, Place the picture on the panel and place the panel in the frame.
Requirement Two:
Method 1
Create a JFrame a JPanel a jlabel through the ImageIO read a picture put the picture into JLabel JLabel put in JPanel JPanel in JFrame
write characters on a picture with a graphics
Import Java.awt.color;import java.awt.graphics;import Java.awt.image.bufferedimage;import Java.io.File;import Java.io.ioexception;import javax.swing.*;import javax.imageio.*;p ublic class Demo {/** * @param args * @throws exception< C0/>*/public static void Main (string[] args) throws Exception {//TODO auto-generated method stubbufferedimage image = Ima Geio.read (New File ("f:\\fd.jpg")); Graphics g = Image.getgraphics (); G.setcolor (color.red); G.drawchars ("by Michael". ToCharArray (), 0, 10, 10, 10); G.setcolor (Color.green); G.drawchars ("I Process the picture". ToCharArray (), 0, "I process the picture". Length (), Image.getwidth ()-80, Image.getheight ()-10); JFrame JM = new JFrame (); Jm.setbounds (n, A, A, a), ImageIcon IC = new ImageIcon (); JPanel panel = new JPanel (); JLabel JL = new JLabel (new ImageIcon (image));p Anel.add (JL); Jm.getcontentpane (). Add (Panel); jm.setvisible (True);}}
Java experiment 8-java input/output stream