Read about how to write data in file in java, The latest news, videos, and discussion topics about how to write data in file in java from alibabacloud.com
Believe that everyone has encountered in the introduction of a Chinese string,debug their own every line of code, have found that there is always no garbled (ie: excluded, the source code file encoding format is no problem), but the data into the database is a mess.Then it is obvious that the problem is in the process of writing the data to the database (the enco
Recently because of the internationalization of the project needs, the entire project needs to be 100 or more plug-ins to do internationalization, which is a painful thing, because of pure physical labor. In order to save a bit of work, think can write a program batch processing, reduce the amount of work, so there is the following code.
1. Read the specified (. java)
system code//code
= System.getproperty ("file.encoding");
Code = "GBK";
ISR = new InputStreamReader (new FileInputStream (file), code);
Read the contents of the file int length =-1;
char[] buffer = new char[1024];
StringBuffer sb = new StringBuffer ();
while (length = isr.read (buffer, 0, 1024))!=-1) {sb.append (buffer,0,length);
second parameter in the constructor true indicates that the file is written in append formFileWriter writer =NewFileWriter (FileName,true); Writer.write (content); Writer.close (); } Catch(IOException e) {e.printstacktrace (); } } Public Static voidMain (string[] args) {String fileName= "C:/temp/newtemp.txt"; String content= "New append!"; //append files by method aAppendtofile.appendmethoda (fileName, content); Appendtofile.appendmethoda (F
There are several methods for reading and writing files in Java, but I think the simplest is the fileinputstream and fileoutputstream classes. For example, Code :
Package jmyang. file; import Java. io. *; public class filetest {/** delete file */public static Boolean Delete (string filename) {boolean result = false;
1. Obtain information entered by the console userPublic String getinputmessage () throws ioexception ...{System. Out. println ("Enter your command ");Byte buffer [] = new byte [1024];Int COUNT = system. In. Read (buffer );Char [] CH = new char [count-2]; // the last two digits are the Terminator, delete notFor (INT I = 0; I Ch [I] = (char) buffer [I];String STR = new string (CH );Return STR;}The user input information can be returned. The disadvantage is that Chinese input is not supported and f
Clear,clcnt=735;ny=73; %2.5*2.5 Lattice Point ofnx=144; %2.5*2.5 Lattice Point ofF=NETCDF (' air.mon.mean.nc ', ' nowrite ');tt=f{' air '} (:);Close (f)Fid=fopen (' a5.grd ', ' W ');For It=1:ntFor J=1:nyFor I=1:nxCount= fwrite (Fid,tt (it,j,i), ' float '),% according to example here with raw dataEndEndEndFclose (FID)A5.GRD the corresponding CTL file isDset F:\A5.GRDTitle Monthly mean air temperature NCEP reanalysisOptions Sequential YrevUndef-9.96921e
// Ini configuration file path# Define GOODSCATEGORYENGINE_FILE _ T ("C: \ ClientDirEda ")# Define GOODSCATEGORYENGINE_INI _ T ("C: \ ClientDirEda \ StartX. ini ")
# Define GOODSCATEGORYENGINE_INI_TEST _ T ("C: \ ClientDirEda \ GoodsCategoryEngine. ini ")
CString str = _ T ("I have successfully read the ini configuration file! "), StartXStr;Int fileSize1, fileSize2;// Read the INI FileFileSize1 = GetPri
Java Simple file read and write, yesterday helped students write a simple file processing program, record this side, unexpectedly spent one hours, is because System.out print log when the location of the wrong:-(public static void Main (string[] args) {try{BufferedReader br
Io flow simply means that the input stream and output stream are primarily used to process data transfer between devicesCase 1 is a byte stream, Case 2 is a character stream, the difference between the byte stream and the character stream is very large, and the reader needs to use it according to his own scene.Case 1:Use byte stream and package stream (readers can understand the packaging flow, mainly using the adorner mode) to read and
Java compares IO and NIO file read/write performance tests, ionio
Original article: test the file read/write performance of IO and NIO in java
Source code: http://www.zuidaima.com/share/1550463508466688.htm
1. NIO adopts a me
Java write local orc file (Hive2 API)
Hive2.0 later, a new API was used to read and write orc files (https://orc.apache.org).The code in this article generates the Orc file locally using a Java program, and then loads it into the
, the load data local parameters should be removed, and the file name should be the full absolute path name. finally attached LOAD DATA infile Syntax LOAD DATA [Low_priority | CONCURRENT] [LOCAL] INFILE ' file_name.txt ' [REPLACE | IGNORE] into TABLE tbl_name [Fields [ TERMINATED by ' string ') [[optionally] en
1. Overview of Bufferedoutputstream/bufferedinputstream (byte buffer stream)It is really much faster to define an array than it was to read one byte at a time, so it seems that a buffer is still very good. Since this is the case, then, when Java began to design, it also took into account this problem, it is specifically provided with a buffer byte class. This class is called: Buffer Class (High efficiency Class)
Related Information
Java Excel is an open source project through which Java developers can read the contents of Excel files, create new Excel files, and update existing Excel files. Using this API non-Windows operating systems can also work with Excel data tables through a pure Java application. Because it is written i
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.