Move Int to Char
Hi All,
I have a table with some fields of type int. This needsto be moved to another table with fields of type char. Kindly suggest a solution to this.
Note: A move statement between the tables isn't working.
Thanks,
Esha Raj
hi,
Use write to statement ..
write v_int to v_char.
Regards,
Santosh
Similar Messages
-
hello.
How can I move out the char Θ (unicode U+0398) оn Jspx-page used af:outputlabel.
When I write <af:outputLabel value="27. char(Θ)" />, application auto replace on char "?".
thx, Dema.Hello
Probably an encoding problem.
try changing your charset into your JSP:
ex: <jsp:directive.page contentType="text/html;charset=UTF-8"/>
I tried it and it works for me
Jack -
Hi,
How can I convert from an int to char?The challange is to convert from int to String without using any API or automatic conversionWoah, what a challenge ! Why ?
Anyway, what about a recursive call and switch statement. Something likepublic String intToString(int n) {
if(n<0) {
return "-"+intToString(-n);
if(n<10) {
return getStringDigit(n);
else {
return intToString(n/10) + getStringDigit(n%10);
private String getStringDigit(int n) {
switch(n) {
case 0:
return "0";
// etc.
} -
I've got a method I'm working on that looks like this:
private static String generatePassword()
String pass = "";
int randomInt;
char a;
for(int i = 1; i <= PASSWORD_LENGTH; i++)
randomInt = generator.nextInt();
a = (char)randomInt;
pass = pass + a;
System.out.print(pass);
return pass;
What I'm trying to do here is create a randomly generated password that consists of five characters. Password_Length is a static variable set to 5. I'm having a problem typecasting the randomInt into a character. Everytime I do this, my display comes back as 'boxes' for each character. If anyone can help, it'd be appriciated.private static String generatePassword()
String pass = "";
int randomInt;
char a;
for(int i = 1; i <= PASSWORD_LENGTH; i++)
randomInt = (int)(((double)('z'-'a'))*java.lang.Math.random());
if(java.lang.Math.random()<0.5)
randomInt -= ('a'-'A');
a = (char)randomInt;
pass = pass + a;
System.out.print(pass);
return pass;
} -
Int to Char...I don't know what the problem is here
Everything compiles fine here, and if I print out the "encryption" variable I get what looks like it would be right, converted into chars, but when I try to convert the int to char(my char variable for that is 'w'), my compiler freaks out, I don't even know what it's doing it doesn't give me an error, but sometimes it prints out nothing but sometimes it prints out "puTTypUTtypuTTYPUtty" ...why is it doing that and what is wrong with what I am doing?.
public class encrypt
public static void main(String[] args)
String plainText = "hello, my name is christy.";
String keyWord = "nice to meet you";
int encryption = 0;
char ch = 'a';
char c = 'a';
int encryptor = 0;
int charCode;
int sum = 0;
char w;
int i = plainText.length();
int j = plainText.length();
int[] plain = new int;
int[] key = new int[j];
for(i=0; i<plainText.length(); i++)
ch = plainText.charAt(i);
charCode = (int)ch;
if(charCode > 97 && charCode < 122)//make lowercase
{charCode = charCode - 97;}
if(charCode > 65 && charCode < 90)
{charCode = charCode - 65;}
plain[i] = charCode;
for(j=0; j<keyWord.length(); j++)
c = keyWord.charAt(j);
int chCode = (int)c;
if(chCode > 97 && chCode < 122)
{chCode = chCode - 97;}
if(chCode > 65 && chCode < 90)
{chCode = chCode - 65;}
key[j] = chCode;
encryption = (plain[i] + key[j]) % 26;
w = (char)encryption;
System.out.print(w);And for that matter, use increment/decrement assignment operators (like += and -=) instead of verbosely repeating the variable. And if you're going to use character-by-character case conversion, use the methods in Character don't do it like a C programmer circa 1982. And if this is anything other than a homework assignment, use encryption code provided in the JDK; don't reinvent it.
-
From int to char...
Got a nice little problem: I have an int (e.g. int i = 111). This should be transformed into the appropriate ASCII-Code char (or UNICODE-char, if only this is possible). Sounds easy but I didn't manage it.
In desperate need for help... :-)
Hannibal_
Thanx!Have you ever tried to cast an int to char? I've tried it for hours now but I didn't get it right. There is no problem to specify a char by giving it an int value (char c = 111) but to cast an int to char. It's not possible to do it like this:
char c;
int i = 111;
c = i;
Thanx! -
Necesito saber cual es la instruccion en cvi que convierte int a char
Usa sprintf(char Destino, const char Formato, origen_de_datos), que esta en la libreria ANSI C. Es una funcion general que genera un string de chars con cualquier tipo de datos.
Debes declarar un char Destino del largo necesario para que contenga todo el numero (aprox. 6 caracteres para un int). El char formato es del tipo "%d" para un entero
Ej
int Entero;
char EnteroConvertido[6];
sprintf(EnteroConvertido,"%d",Entero); -
Hello,
How can I convert an int variable representing a character to a char variable?
Thanks.Nononono; you must get it straight: as everybody well
knows the Lewis/Clark
approach suffers from negative zeros in their one
complement scheme; that's
why the latest JTCAPI abondoned it in their final
draft proposed at the JCP#56632
sabre and I are right and you are dead wrong; so
there :-P
kind regards,
JosI'll never never never never never never never believe you, no matter how many times you damn oligarchs post the truth, no matter how many times you back it up with supporting references. NA NA NA NA NA NA NA I CAN'T HEEEAAAR YOUUUU!
World spins
RD-R
� {� -
I have 2 methods.
The first method takes an int from 0-256 and casts it to a char and then places the char in a string:
cCryptedString [iLoop] = (char) iCryptedValue;
The second method reads the string and casts each character from it into an int.
iPassStringValue = (int) aString.charAt(iLoop);
If the iCryptedValue in the 1st method is > 127 and < 150 (because that's as far as they will go at the moment), the casting of that int (i.e. 145) to a char results in a ? being placed in cCryptedString[iLoop].
When the 2nd method reads the string and encounters the ? placed by the first method, the casting of that char to an int results in a 63 (the ascii value of a ?) instead of the original 145.
This was not a problem until I installed and ran WebLogic 6.0 sp2 using jdk 1.3 on a Windows 2000 machine. It is working fine under WebLogic 5.1 using jdk 1.2.2.
Any ideas?
Thanks,
MarkHere is the 1st method:
public String encryptString(String aString) {
int iPassStringValue = 0;
int iEncryptKeyValue = 0;
int iCryptedValue = 0;
char cCryptedString [] = new char[aString.length()];
for (int iLoop = 0; iLoop < aString.length(); iLoop++) {
iPassStringValue = (int) aString.charAt(iLoop);
iEncryptKeyValue = (int) sEncryptKey.charAt(iLoop);
iCryptedValue = iPassStringValue + iEncryptKeyValue;
if (iCryptedValue > 255)
iCryptedValue = iCryptedValue - 256;
cCryptedString [iLoop] = (char) iCryptedValue;
return new String(cCryptedString);
Here is the 2nd method:
public String decryptString(String aString) {
int iPassStringValue = 0;
int iEncryptKeyValue = 0;
int iDecryptedValue = 0;
char cDecryptedString [] = new char[aString.length()];
for (int iLoop = 0; iLoop < aString.length(); iLoop++) {
iPassStringValue = (int) aString.charAt(iLoop);
iEncryptKeyValue = (int) sEncryptKey.charAt(iLoop);
iDecryptedValue = iPassStringValue - iEncryptKeyValue;
if (iDecryptedValue < 0)
iDecryptedValue = iDecryptedValue + 256;
cDecryptedString [iLoop] = (char) iDecryptedValue;
return new String(cDecryptedString);
Thanks!! -
Hi!..
I have a problem!...
I need to convert integers to chars, but i`m using char(int)....
So, only accept until ascii code 128..
Please, What can I do?
This is my code:
Thanks!
public Convert() {
public static void main(String[] args) {
Convert convert1 = new Convert();
System.out.print(f_Transforma("ABCD"));
public static String f_Transforma(String Password)
int IntStrLong=Password.length();
String StrResultado=new String();
while (IntStrLong >=1)
int tmpchar=(int)Password.charAt(IntStrLong-1); //valor ascii
tmpchar=256-tmpchar+IntStrLong;
String aChar = new Character((char)tmpchar).toString(); //ASCII code to String
StrResultado=StrResultado+aChar;
IntStrLong-=1;
return (StrResultado);
}I did what you told me and nothing happened...
int tmpchar=(int)Password.charAt(IntStrLong-1); //valor ascii
tmpchar=256-tmpchar+IntStrLong;
tmpchar=tmpchar>>8;
String aChar = new Character((char)tmpchar).toString(); //ASCII code to String -
How to change int to char?
hie was wondering if anyone could help me
i want to take an integer (lets say int y = 9)
and change it to char x = y . is it possible?Doesn't work.
public class intToChar {
public static void main( String[] args ) {
int i = 10;
char c = (char) i;
System.out.println("Int is " + i);
System.out.println("Char is " + c);
[/code/
Above code prints:Int is 10
Char is
I've looked in the online API documentation for Character and Integer and found nothing that appears to do what you want to do. I actually wonder if this is possible in core java or if you have to pull some unicode chicanery? Eagerly awaiting reply from someone who knows...
Maduin -
Int to Char for arraylist quicksort
Hey, i need help as our teacher was decent but he went through the sorting extremely quickly so it was hard to understand. Therefore i need help changing this to a char which reads Strings. It currently reads GPA(int) but i need it to read last names and first names (string ------> chars) here is the code i have:
import java.util.ArrayList;
public class SortGPA {
private void SortGPA(ArrayList list, int low0, int high0) {
int low = low0, high = high0;
if (low >= high) {
return;
} else if (low == high - 1) {
if (((Comparable)list.get(low)).compareTo(list.get(high)) > 0) {
Object temp = list.get(low);
list.set(low, list.get(high));
list.set(high, temp);
return;
Object pivot = list.get((low + high) / 2);
list.set((low + high) / 2, list.get(high));
list.set(high, pivot);
while (low < high) {
while (((Comparable)list.get(low)).compareTo(pivot) <= 0 && low < high) {
low++;
while (((Comparable)list.get(high)).compareTo(pivot) >= 0 && low < high) {
high--;
if (low < high) {
Object temp = list.get(low);
list.set(low, list.get(high));
list.set(high, temp);
list.set(high0, list.get(high));
list.set(high, pivot);
SortGPA(list, low0, low - 1);
SortGPA(list, high + 1, high0);
public void sort(ArrayList list) {
SortGPA(list, 0, list.size() - 1);
}And for that matter, use increment/decrement assignment operators (like += and -=) instead of verbosely repeating the variable. And if you're going to use character-by-character case conversion, use the methods in Character don't do it like a C programmer circa 1982. And if this is anything other than a homework assignment, use encryption code provided in the JDK; don't reinvent it.
-
.mov comments tagging char limit??!!
Adding comments to .mov files in iTunes I notice that upon finishing the dialogue disappears as if everything is okay.. but its not as there seems to be a limit to the amount of characters one can use in the comments field.
The problem I have it that no notification is given to signify the cut off point, like a ticker with remaining chars left, or that the whole of the text written is not embedded. This is quite unsettling, can anybody please confirm if there is a limit.I just received a reply from a metadata pro telling me that the mov format has no char restrictions for the comments field and it must be iTunes that is restricting the comments I can leave. Humf.
I emailed Apple about this, I think that comments should be infinite in size, I like a good story with my movies, that I shot. On the other hand (unlike the iPhone v2.0 software) he said that as mov is an Apple format that there would be no data corruption from tagging with iTunes :)) -
HOW can I convert int value char TO String
I am trying to study Java by books, but sometimes it is quite difficult to find answers even to simple questions...
I am writing a program that analyzes a Chinese text in Unicode. What I get from the text is CHAR int value (in decimals), and now I need to find them in another text file (with RegEx). But I can't find a way how to convert an INT value of a char into a String.
Could you help me?
Thank you in advance.You are confusing matters a bit. A char is a char is a char, no matter
how you represent it. Have a look at this:char a= 'A';
char b= 65;Both a and b have the same value. The representation of that value
can be 'A' or 65 or even (char)('B'-1), because the decimal representation
of 'B' is 66. Note the funny construct (char)(...). This construct casts
the value ... back to the char type. Java performs all non-fraction
arithmetic using four byte integers. The cast transforms it back to
a two byte char type.
Strings are just concatenations of zero or more chars. the charAt(i)
method returns you the i-th char in a string. Have a look:String s= "AB";
char a= 'A';
char b= (char)(a+1);
if (a == s.charAt(0)) System.out.println("yep");
if (b == s.charAt(1)) System.out.println("yep");This piece of code prints "yep" two times. If you want to compare two
Strings instead, you have to do this:String s= "AB";
char a= 'A';
char b= 'B';
String t= ""+a+b;
if (s.equals(t)) System.out.println("yep");Note the 'equals' method instead of the '==' operator. Also note that
string t was constructed using those two chars. The above was a
shorthand of something like this:StringBuffer sb= new StringBuffer("");
sb.append(a);
sb.append(b);
String t= sb.toString();This is all handled by the compiler, for now, you can simply use the '+'
operator if you want to append a char to a string. Note that it is not
very efficient, but it'll do for now.
Does this get your started?
kind regards,
Jos -
I am developing a program that generates a SIP message. For the branch tag of Via header field i need to generate random mixture of integers and strings....sth like this (89hg823Hjkg8).
I know how to generate int and string separately....but ive no idea how to generate the mixture of two. help
thanx in advanceYou could use java.util.Random to generate random numbers from 48 to 122 inclusive and then cast it as a char. Only problem is that several of the numbers within this range represent other characters such as ? > @ etc.
Maybe you are looking for
-
I can't open iTunes on a lenovo with a Windows 8.1 operating system. I get the following message... The iTunes Library Extras.itdb file is locked, on a locked disk, or you do not have write permission for this file. PLEASE HELP!!
-
My iPad has been erased. I am not be able to find the prevues owner to use the iCloud account to activate my iPad. If there is a way please help me.
-
How to read multiple files in the same folder?
Suppose I have 100 txt files in the same folder, and I want to read them one by one. (order is not important). File name is also part of the information I want. How to do that? Thanks
-
How to track PropertyChangeEvent for the backing beans?
Hello I'm working on JSF 1.2 + JDK 1.6. Would like to know wether any direct support for tacking the PropertyChangeEvent for the backing bean. Objective is to keep track of the modified entities ( backing bean) and update the corresponding Database r
-
Can you sign into Adobe CreatePDF from different desktops?
I am looking into purchasing Adobe CreatePDF for administrative work that I do for my job. The problem is that I don't have a set work station and am changing desktop computers in the office frequently. I was wondering if I can sign into Adobe Create