View RSS Feed

fatabass

Reading Byte From a Text File and Printing To Console Character And Byte Value

Rating: 1 votes, 1.00 average.
by , 01-14-2012 at 12:12 PM (1847 Views)
Java Code:
public static void main(String[] args) 
	{
		File myText = new File("c:/myDir/myText.txt");
		
		try {
			InputStream myByteReader = new FileInputStream(myText);
			System.out.println("Available total bytes:" + myByteReader.available());
			int firstByte = myByteReader.read();
			System.out.println("First byte:" + firstByte);
			System.out.println("Char of first byte:" + (char) firstByte);
			myByteReader.close();
		} catch (FileNotFoundException e) {

		} catch (IOException e) {

		}
	}

Submit "Reading Byte From a Text File and Printing To Console Character And Byte Value" to Facebook Submit "Reading Byte From a Text File and Printing To Console Character And Byte Value" to Digg Submit "Reading Byte From a Text File and Printing To Console Character And Byte Value" to del.icio.us Submit "Reading Byte From a Text File and Printing To Console Character And Byte Value" to StumbleUpon Submit "Reading Byte From a Text File and Printing To Console Character And Byte Value" to Google

Tags: None Add / Edit Tags
Categories
Uncategorized

Comments