Http://www.cnblogs.com/LiHuiGe8/p/5604725.html read the assets file data in the asset directory is not directly accessible to the resources of the native resources, but this directory saved files can be packaged in the program, Android apps manage the raw resources in this directory through Assetmanager. Android does not generate IDs for files under assets, such as to use files in assets, you need to specify the path and file name of the file. Code Usage Example: (1) Create file in assets: Info.
://www.baidu.com"); 4 InputStream is = Url.openstream ();//Gets the byte input stream of a resource through the OpenStream Method 5 InputStreamReader ISR =newinputstreamreader (IS, "UTF-8 ");//convert byte input stream to character input stream, if no encoding is specified, Chinese may garbled 6 BufferedReader BR =newbufferedreader (ISR);//Add buffer for character input stream, improve reading efficiency 7
string?FileInputStream fis = new FileInputStream ("Osw.txt");InputStreamReader ISR = new InputStreamReader (FIS, "GBK");int d =-1;while ((d = isr.read ())! =-1) {System.out.println ((char) d);}char[] data = new CHAR[100];int len = isr.read (data);String str = string.valueof (data, 0, Len);System.out.println (str);Isr.close ();Read () or read (char[]) method using the ISRYou can also specifyInputStreamReader ISR
byte input stream is obtained through the OpenStream method, i.e. InputStream
Wrap the InputStream into a character input stream InputStreamReader ( constructed according to the encoding format of the Web page )
Packed into buffered streams for increased efficiency
Declares a string to store the read content through the while loop output (not unique)
Close all the streams, close
1URL url=NewURL ("http://www.baidu.com");2 //get byte input stream through OpenStream me
.propertiesEdit copy:
Config/server-1.properties:
broker.id=1
listeners=plaintext://:9093
log.dir=/tmp/kafka-logs-1
Config/server-2.properties:
broker.id=2
listeners=plaintext://:9094
log.dir=/tmp/kafka-logs-2The Broker.id attribute must be unique for each node. Using a different log directory is for each node to store its own log files and not overwrite each other.
Start these two nodes:
> bin/kafka-server-start.sh config/server-1.properties
...
> bin/kafka-server-
clearly, which is no longer described here. In addition, the operation of HDFS files requires the use of Core-site.xml and Hdfs-site.xml files in the Hadoop directory. Code Snippets
Configuration:
Configuration conf = new configuration ();
FileSystem HDFs = Filesystem.get (Uri.create ("Hdfs://nameservice/path"), conf, "username");
HDFs file read and write operations:
public void Writercontenttohdfs (string hdfsfile, string content) {OutputStream OS = null;
OutputStreamWriter OSW = null;
Cmsis-rtos2 Universal RTOs Interface
Cmsis-rtos2 is a generic API that is independent of the underlying RTOS kernel. The programmer calls the Cmsis-rtos2 API function in user code to ensure maximum portability from one RTOs to another. Use the middleware of the Cmsis-rtos2 API to avoid unnecessary porting efforts.
The typical CMSIS-RTOS2 API is implemented with an existing real-time kernel interface. The Cmsis-rtos2 API provides the following properties and features:Thread management allows
/*** Data requests using the Get method of HTTP*/ protected voidHttpGet () {/*** Make asynchronous requests*/ NewAsynctask() {@OverrideprotectedVoid doinbackground (String ... params) {System.err.println ("HttpGet Start"); //data processing is only possible in this method and cannot interact with UI Try{URL URL=NewURL (params[0]); URLConnection Connection=url.openconnection (); InputStream is=Connection.getinputstream (); //data stream conversion using UTF-8, from byte f
the encoding method, the underlying operating system uses the default encoding method, such as GBK. When using FileReader to read files.
FileReader fr = new FileReader ("ming.txt ");
Int ch = 0;
While (ch = fr. read ())! =-1)
{
System. out. print (char) ch );
}
The read () method returns the read to get the next character. Of course, you can also use read (char [] ch, int off, int length), which is similar to processing binary files. If you use InputStreamReader to read files
While (ch =
(char [] ch, int off, int length), which is similar to processing binary files. If you use InputStreamReader to read filesWhile (ch = isr. read ())! =-1){System. out. print (char) ch );}This is no different from FileReader. In fact, the methods in FileReader are inherited from InputStreamReader. The read () method is time-consuming. To improve the efficiency, we can use BufferedReader to package the Reader. In this way, the read speed can be improved
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.