codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  lowerCase to UpperCase  subito at 14:19 on Thursday, March 24, 2005
 

I am having trouble changing text form upperCase to lowerCase. I am trying to read in a file and change the first letter of the word to lowerCase and the second word to upperCase and delete the spaces in between. Example:


Control Measure Mapping (needs to look like) controlMeasureMapping. I have provided the code that I have so far. If anyone can HELP, I would really appreciate it.

import java.io.*;
import javax.swing.*;


class BufferReaderDemo {

public static void main(String args[]) {

try {
FileReader fr = new FileReader("/forum/CDocuments_and_SettingsrwhitehurstDesktopTest.txt");
BufferedReader br = new BufferedReader(fr);

String s;

int ToCharArray[] = new int[4];
String output = "Index\tValue\n";

while((s = br.readLine()) != null){
if (s.length() > 0)
{

}
System.out.println(s);
}

fr.close();

}
catch(Exception e) {
System.out.println("Exception: " + e);
}
}
}


  Re: lowerCase to UpperCase  raik at 18:46 on Friday, March 25, 2005
 

suppose u have a string like below

String abc="Kamal Khan Great"

create an array type variable and split abc string with space

Array splitstring=abc.Split(" ")

create another string variable like below

String Resultstring= splitstring(0).ToLower()
Resultstring += Resultstring(1) & Resultstring(2)

  Re: lowerCase to UpperCase  sels at 11:43 on Monday, March 28, 2005
 

try the following code.


import java.io.BufferedReader;
import java.io.FileReader;


public class BufferReaderDemo
{

public static void main(String args[])
{
try
{
FileReader fr = new FileReader("/forum/CTest.txt");
BufferedReader br = new BufferedReader(fr);

String s;
int tmp=0;
String ostring = "";
String nstring="";


while((s = br.readLine()) != null)
{
ostring=ostring+s;
}

fr.close();
br.close();

for(int k=0;k<ostring.length();k++)
{
if((int)ostring.charAt(k)!=32)
{
nstring=nstring+ostring.charAt(k);
}
}
if((int)ostring.charAt(0)>=65 && (int)ostring.charAt(0) <=90)
{
tmp = (int)ostring.charAt(0)^32;
nstring=nstring.replace(ostring.charAt(0),(char)tmp);
}
System.out.println("nstring is " + nstring);
}
catch(Exception e)
{
System.out.println("Exception: ");
e.printStackTrace();
}
}

}

Thanks.








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  do static member are inherited
•  Re: Help with Using DataReader with StoredProcedure
•  Perl Script Output (w3c validator)
•  Re: HashMap question
•  focus management?
•  Looping Issue...Please help!
•  regarding hibernate
•  working with plugins
•  Checkbox Validation help.


Recent Articles
What is a pointer in C?
Multiple submit buttons with form validation
Understanding Hibernate ORM for Java/J2EE
HTTP screen-scraping and caching
a javascript calculator
A simple way to JTable
Java Native Interface (JNI)
Parsing Dynamic Layouts
MagicGrid
Caching With ASP.Net


© Copyright codetoad.com 2001-2006