473,320 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

need help on char array

JC
hi

i want to check a char in the char array

public void characters(char[] chars, int start, int length)
{
if (chars!='/n' || chars((char)'/r'))
{
System.out.println("String read is " +
new String(chars, start, length));
}
}

thanks

JC
Jul 17 '05 #1
4 8151

"JC" <JC@JC.com> wrote in message news:40**********@rain.i-cable.com...
hi

i want to check a char in the char array

public void characters(char[] chars, int start, int length)
{
if (chars!='/n' || chars((char)'/r'))
{
System.out.println("String read is " +
new String(chars, start, length));
}
}


I hope you know that this line:

if (chars!='/n' || chars((char)'/r'))

should be something like [assuming you want to eliminate both newline and
carriage return]:

if (chars[i] != '\n' && chars[i] != '\r')

The expanded code, though I'm not certain what it is you are wanting to
accomplish:

for (int i = 0; i < chars.length; ++i)
{
...
if (chars[i] != '\n' && chars[i] != '\r')
{
...
}
}

I hope this helps.

Anthony Borla

Jul 17 '05 #2

"JC" <JC@JC.com> wrote in message news:40**********@rain.i-cable.com...
hi

i want to check a char in the char array

public void characters(char[] chars, int start, int length)
{
if (chars!='/n' || chars((char)'/r'))
{
System.out.println("String read is " +
new String(chars, start, length));
}
}


I hope you know that this line:

if (chars!='/n' || chars((char)'/r'))

should be something like [assuming you want to eliminate both newline and
carriage return]:

if (chars[i] != '\n' && chars[i] != '\r')

The expanded code, though I'm not certain what it is you are wanting to
accomplish:

for (int i = 0; i < chars.length; ++i)
{
...
if (chars[i] != '\n' && chars[i] != '\r')
{
...
}
}

I hope this helps.

Anthony Borla

Jul 17 '05 #3
JC
i use a for loop before. but no use for my coding. i need to read a XML file
and save all these data to a java array. i want to skip the return and new
line char. Can anyone give me some idea?

Thanks

JC

"Anthony Borla" <aj*****@bigpond.com> wrote in message
news:wc*****************@news-server.bigpond.net.au...

"JC" <JC@JC.com> wrote in message news:40**********@rain.i-cable.com...
hi

i want to check a char in the char array

public void characters(char[] chars, int start, int length)
{
if (chars!='/n' || chars((char)'/r'))
{
System.out.println("String read is " +
new String(chars, start, length));
}
}


I hope you know that this line:

if (chars!='/n' || chars((char)'/r'))

should be something like [assuming you want to eliminate both newline and
carriage return]:

if (chars[i] != '\n' && chars[i] != '\r')

The expanded code, though I'm not certain what it is you are wanting to
accomplish:

for (int i = 0; i < chars.length; ++i)
{
...
if (chars[i] != '\n' && chars[i] != '\r')
{
...
}
}

I hope this helps.

Anthony Borla

Jul 17 '05 #4
JC
i use a for loop before. but no use for my coding. i need to read a XML file
and save all these data to a java array. i want to skip the return and new
line char. Can anyone give me some idea?

Thanks

JC

"Anthony Borla" <aj*****@bigpond.com> wrote in message
news:wc*****************@news-server.bigpond.net.au...

"JC" <JC@JC.com> wrote in message news:40**********@rain.i-cable.com...
hi

i want to check a char in the char array

public void characters(char[] chars, int start, int length)
{
if (chars!='/n' || chars((char)'/r'))
{
System.out.println("String read is " +
new String(chars, start, length));
}
}


I hope you know that this line:

if (chars!='/n' || chars((char)'/r'))

should be something like [assuming you want to eliminate both newline and
carriage return]:

if (chars[i] != '\n' && chars[i] != '\r')

The expanded code, though I'm not certain what it is you are wanting to
accomplish:

for (int i = 0; i < chars.length; ++i)
{
...
if (chars[i] != '\n' && chars[i] != '\r')
{
...
}
}

I hope this helps.

Anthony Borla

Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Danny Anderson | last post by:
Hola! I have an array of shorts that represents a stream of data. This data is packed in tight, so certain elements may actually contain data for more than one variable. I am to decipher this...
41
by: Psykarrd | last post by:
I am trying to declare a string variable as an array of char's. the code looks like this. char name; then when i try to use the variable it dosn't work, however i am not sure you can use it...
12
by: arkobose | last post by:
my earlier post titled: "How to input strings of any lengths into arrays of type: char *array ?" seems to have created a confusion. therefore i paraphrase my problem below. consider the...
7
by: Timothy Shih | last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I wrote a simple function which takes in 2 buffers (one a byte buffer, one a char buffer) and copies the contents of the byte...
12
by: gcary | last post by:
I am having trouble figuring out how to declare a pointer to an array of structures and initializing the pointer with a value. I've looked at older posts in this group, and tried a solution that...
4
by: ayman723 | last post by:
hi, I'm trying to write a program in wich I would generate 20 sentences out of 4 arrays(articles,nouns,preposition,verb).I have to select an item at random from each array and concatetane each one...
2
by: Gilles Vollant \(MVP\) | last post by:
Hello I've (in WinImage SDK http://www.winimage.com/wima_sdk.htm ) a function that I need to use from a VB.Net apps First, on the unmanaged Win32 DLL, I've a function which get the number of...
1
by: untitled | last post by:
i wrote an application in c++ that capture a motion from a bmp sequence and outputs a 3DS max secript file contains the motions keys. i have two points here need to be fixed: 1- it is an offline...
4
by: Paul David Buchan | last post by:
Hello, I'm attempting to write a program to read in database files (.dbf). When I do it all as a single procedure in main, everything works. However, what I really want, is to pass the database...
12
by: Nezhate | last post by:
Hi There, I'm writing a program that takes a decimal number and returns it's binary equivalent. the problem is that I don't know how to return (from function) the binary value as an array of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.