Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Int to char.

Status
Not open for further replies.

adiMasher

Programmer
Aug 31, 2001
144
US
Okay so I'm using bufferedreader for my input stream

Code:
br = new BufferedReader(new FileReader(fileLoc) );
and I want to read in character by character which
Code:
myInt = br.read()
will work for that purpose.

However I don't know how to convert from int to something I can use like a string or Char.

Also I want to ignore carriage returns and linefeeds. I know one is 0x0A but what is the value for the other (in the case of int.

Thankx,

Martin If the sky is blue and the Sun is yellow.... Why isn't the air Green?
 
Alright, for those of you playing the home version of this game I'll let you know what I figured out.

Code:
	BufferedReader br;
	int myInt=0;
	char myChar;
        String testFile = "testme.txt";
	try{
		br = new BufferedReader(new FileReader(testFile) );

		while( (myInt = br.read()) > 0 ){
			myChar = (char)myInt;
			if (myChar == '}') {
				System.out.print(myChar);
			}
			// to weed out carriage returns and newlines add this
			if (!((myInt == 10) || (myInt == 13))){
				//no carriage returns or linefeeds here in this nest
			}
		}
		br.close();
	}
	catch(IOException e){
		System.out.println("IOException "+e);
	}
If the sky is blue and the Sun is yellow.... Why isn't the air Green?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top