();
}
}
Copy CodeOperation Result:650) this.width=650; "id=" aimg_294 "src=" http://techfoxbbs.com/data/attachment/forum/201505/22/ 132250nrc1di5kpr2zi16d.png "class=" Zoom "width=" 349 "alt=" 132250nrc1di5kpr2zi16d.png "/>The main disadvantage of this method of reading is to build a byte array as large as the file size, when the file is small, and when the file is large, memory may not be able to frame such a large array of bytes. Therefore, this method is only suitable
1. Use byte stream fileinputstream/fileoutputstream to copy a text file case:Analysis:(1) data source : Where to come fromA.txt--Read data--FileInputStream(2) destination : Where to goB.txt--Write data--FileOutputStream2. code example:1 Packagecn.itcast_03;2 3 ImportJava.io.FileInputStream;4 ImportJava.io.FileOutputStream;5 Importjava.io.IOException;6 7 /*8 * Co
1.FileInputStream, FileOutputStream Two streams are processing binary files. Mainly processing pictures, videos and so on files.
2.FileInputStream: Reads the contents of the binary file.
3.FileOutputStream: Write binary file.
4.FileInputStream, FileOutputStream Method please refer to:Http://tool.oschina.net/apidocs/apidoc?api=jdk-zh
5. Copying pictures is the pro
Package Date0802;import Java.io.fileinputstream;import Java.io.ioexception;public class InputStream {@ Suppresswarnings ("resource") public static void main (string[] args) throws IOException {FileInputStream FileInputStream = new FileInputStream ("1.txt");//Gets the file size byte int length=fileinputstream.available ();//reads a file byte into an array of int b
Fileinputstream
Import Java. io. file; import Java. io. fileinputstream; import Java. io. inputstream; public class testfileinputstream {public static void main (string [] ARGs) throws exception {// The exception is thrown and not processed. // Step 3: use the file class to
1. FileInputStream reading data One byte array at a time byte[]Use FileInputStream to read one byte array at a time:int read (byte[] b) return value : The return value is actually the number of bytes actually read.2. code example:1 PackageCom.himi.fileinputstream;2 3 ImportJava.io.FileInputStream;4 Importjava.io.IOException;5 6 7 8 /**9 * Ten * Use
I/O class includes node stream class and packaged stream class
FileOutputStream and FileInputStream create input/output stream objects of Disk Files
When you create a FileInputStream instance object, the specified file should exist and be readable. When you create a FileOutputStream instance object, if the specified file already exists, the original content in the file will be cleared.
When creating a FileO
Write a simple program that allows you to enter content into a program from a file in a disk on your computer.Package Com.liaojianya.chapter5;import Java.io.fileinputstream;import Java.io.filenotfoundexception;import java.util.scanner;/** * This program demonstrates Scanner class * @author LIAO Jianya * */public class Scannertest2{public static void Main (string[] args) throws Filenotfoundexception{//file file = new file ("f:\\", "HelloWorld.txt");//fileinpu TStream in = new
PackageA.ab;ImportJava.io.FileInputStream;Importjava.io.FileNotFoundException;ImportJava.io.FileOutputStream;Importjava.io.IOException; Public classAC {ints = 0; Public Static voidMain (string[] args) {FileOutputStream fos=NULL; Try{fos=NewFileOutputStream ("D:\\dd\\ff.txt"); } Catch(filenotfoundexception E2) {//TODO auto-generated Catch blockE2.printstacktrace (); } Try{fos.write ("Ddsfs, the high speed of the east, and the low V is VSDF". GetBytes ()); } Catch(IOException E1) {e1.print
The input and output of Java is based on 4 abstract classes: InputStream, OutputStream, Reader, Writer. Inputsream and OutputStream are designed as byte-stream classes, while reader and writer are designed as character stream classes. In general, you should use a character stream class when working with characters or strings, and you should use a byte stream class when working with bytes or binary objects.Generally in the operation of the file stream,
1. Need: Copy d:\\ beautiful. jpg to the current project directory Mn.jpgcode example:1 Packagecom.himi.filecopy;2 3 ImportJava.io.FileInputStream;4 ImportJava.io.FileOutputStream;5 Importjava.io.IOException;6 7 /**8 * 9 * Requirement: Copy d:\\ beautiful. jpg to the current project directory Mn,jpgTen * One */ A Public classcopyjpg { - - Public Static voidMain (string[] args)throwsIOException { the //Data Source -
Files object
File F = new file ("D:" + File.separator + "test.txt");
//2nd step: Instantiating a parent class object from a subclass
Reader reader = null;
//Prepare an input object for instantiation by object polymorphism
reader = new FileReader (f);
//3rd step: Read, all the contents are read in this array
char c[] = new char[1024];
int len = Reader.read (c);
//4th step: Turn off the input stream
Reader.close ();
//Change char array to string output
System.out.prin
String Realpath = Request.getrealpath ("web-inf/classes/com/properties/devicetype.properties");The above is the most correct way to get the path, so the properties can be placed under a COM package, or in the SRC directory.Properties props =NewProperties (); ArrayList Al=NewArrayList (); Try{InputStream in=NewBufferedinputstream (NewFileInputStream (Realpath)); Props.load (in); Enumeration en=Props.propertynames (); while(En.hasmoreelements ()) {String key=(String) en.nextelement
1. Requirements: Copy the D:\\english.mp4 to the current project directory Copy.mp4code example:1 Packagecom.himi.filecopy;2 3 ImportJava.io.FileInputStream;4 ImportJava.io.FileOutputStream;5 Importjava.io.IOException;6 7 /**8 * 9 * Requirements: Copy the D:\\english.mp4 to the current project directory Copy.mp4Ten * One */ A Public classCOPYMP4 { - - Public Static voidMain (string[] args)throwsIOException { the //Data Source -
Java programming example code based on three algorithm questions of quick sorting, java example
Overview
Quick sorting is an update of the Bubble sorting we have learned before. They all belong to the exchange sorting class and are sorted by continuous comparison and movement. Quick sorting is a very efficient sorting
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.