Search Results

Search found 4929 results on 198 pages for 'character'.

Page 79/198 | < Previous Page | 75 76 77 78 79 80 81 82 83 84 85 86  | Next Page >

  • Java Scanner class reading strings

    - by Max
    I've created a scanner class to read through the text file and get the value what I'm after. Let's assume that I have a text file contains 1 : Fnjiei : ID 7868860 : Age 18 2 : Oipuiieerb : ID 334134 : Age 39 3 : Enekaree : ID 6106274 : Age 31 I'm trying to get a name and id number and age, but everytime I try to run my code it gives me an exception. Here's my code. Any suggestion from java gurus?:) public void readFile(String fileName)throws IOException{ Scanner input = null; input = new Scanner(new BufferedReader(new FileReader(fileName))); try { while (input.hasNextLine()){ int howMany = 3; System.out.println(howMany); String userInput = input.nextLine(); String name = ""; String idS = ""; String ageS = ""; int id; int age; int count=0; for (int j = 0; j <= howMany; j++){ for (int i=0; i < userInput.length(); i++){ if(count < 2){ // for name if(Character.isLetter(userInput.charAt(i))){ name+=userInput.charAt(i); // store the name }else if(userInput.charAt(i)==':'){ count++; i++; } }else if(count == 2){ // for id if(Character.isDigit(userInput.charAt(i))){ idS+=userInput.charAt(i); // store the id } else if(userInput.charAt(i)==':'){ count++; i++; } }else if(count == 3){ // for age if(Character.isDigit(userInput.charAt(i))){ ageS+=userInput.charAt(i); // store the age } } id = Integer.parseInt(idS); // convert id to integer age = Integer.parseInt(ageS); // convert age to integer Fighters newFighters = new Fighters(id, name, age); fighterList.add(newFighters); } userInput = input.nextLine(); } } }finally{ if (input != null){ input.close(); } } } My appology if my mere code begs to be changed.

    Read the article

  • Collision detection between layers in Cocos2d?

    - by ipodfreak0313
    I am making a game in Cocos2d. I have enemies that shoot, and have the character shoot. I created a separate layer for the enemies (and their bullets) and a separate layer for the character (and its bullets). The problem is, I don't know how to detect collisions between the two layers. Note, I have the Scene in HelloWorldLayer, and each of the above layers is a child of the scene. Any help is appreciated. Thanks!

    Read the article

  • How can I replace ” with " in ASP.NET SQL?

    - by vamsivanka
    I am trying to run this SQL from ASP.NET 2005 but am getting an invalid SQL error because it has a weird character ” in it. In my code I am trying to replace ” with " but it is not doing it as the special character in the replace command is changing to ". Query: insert into userquery(description) values ('In fact, Topeka Google Mayor Bill Bunten expressed it best: “Don’t be fooled. Even Google recognizes that all roads lead to Kansas, not just yellow brick ones.”') If I copy and execute this in mysql it is working good. How can I solve this problem?

    Read the article

  • Javascript split with RegEx

    - by Rohan
    Hey again, I just asked a question about Regex, and received a great answer: http://stackoverflow.com/questions/3047201/javascript-split-without-losing-character Now, I have another question. My current Regex looks like this: var split = text.split(/(?=\w*\d*\d:\d\d)/); Basically, I'm trying to split using the timestamps (eg - 9:30 or 10:30, the difference between them is the extra digit in the latter). How do I go about this? Currently, if I have these two: 9:30 pm The user did action A. 10:30 pm Welcome, user John Doe. The splits are : 9:30 pm The user did action A. ---- 1 ---- 0:30 pm Welcome, user John Doe. How do I add an optional check for the first character in the timestamp? Thanks!

    Read the article

  • C++: Why does space always terminate a string when read?

    - by Nullw0rm
    Using type std::string to accept a sentence, for practise (I haven't worked with strings in C++ much) I'm checking if a character is a vowel or not. I got this: for(i = 0; i <= analyse.length(); i++) { if(analyse[i] == 'a' || analyse[i] == 'e' [..etc..]) { ...vowels++; } else { ... ...consenents++; } This works fine if the string is all one word, but the second I add a space (IE: aeio aatest) it will only count the first block and count the space as a consenent, and quit reading the sentence (exiting the for loop or something). Does a space count as no character == null? Or some oddity with std::string?, It would be helpful to know why that is happening!

    Read the article

  • How to encode and decode chinese characters?

    - by melaos
    I've try googling around but wasn't able to find what charset that this text below belongs to: 具有éœé›»ç”¢ç”Ÿè£ç½®ä¹‹å½±åƒè¼¸å…¥è£ç½® But putting <meta http-equiv="Content-Type" Content="text/html; charset=utf-8"> and keeping that string into a html file i was able to view the chinese character wording properly. which is: ??????????????? So my question is: what tools can i use to detect the character set of those text? And how do i convert/encode/decode them properly in C#? Updates: Added some test code [TestMethod] public void TestMethod1() { string encodedText = "具有éœé›»ç”¢ç”Ÿè£ç½®ä¹‹å½±åƒè¼¸å…¥è£ç½®"; Encoding encoder = new UTF8Encoding(); byte[] postBytes = encoder.GetBytes(encodedText); postBytes = UTF8Encoding.Convert(Encoding.UTF8, Encoding.Unicode, postBytes); string decodedText = Encoding.Unicode.GetString(postBytes); Assert.AreNotEqual(encodedText, decodedText); } thanks

    Read the article

  • How to determine on which file system a file was created in Java

    - by rafrafUk
    Hi Everyone! I get files in different formats coming from different systems that I need to import into our database. Part of the import process it to check the line length to make sure the format is correct. We seem to be having issues with files coming from UNIX systems where one character is added. I suspect this is due to the return carriage being encoded differently on UNIX and windows platform. Is there a way to detect on which file system a file was created, other than checking the last character on the line? Or maybe a way of reading the files as text and not binary which I suspect is the issue? Thanks Guys !

    Read the article

  • Problem with pointer copy in C

    - by Stefano Salati
    I radically re-edited the question to explain better my application, as the xample I made up wasn't correct in many ways as you pointed out: I have one pointer to char and I want to copy it to another pointer and then add a NULL character at the end (in my real application, the first string is a const, so I cannot jsut modify it, that's why I need to copy it). I have this function, "MLSLSerialWriteBurst" which I have to fill with some code adapt to my microcontroller. tMLError MLSLSerialWriteBurst( unsigned char slaveAddr, unsigned char registerAddr, unsigned short length, const unsigned char *data ) { unsigned char *tmp_data; tmp_data = data; *(tmp_data+length) = NULL; // this function takes a tmp_data which is a char* terminated with a NULL character ('\0') if(EEPageWrite2(slaveAddr,registerAddr,tmp_data)==0) return ML_SUCCESS; else return ML_ERROR; } I see there's a problem here: tha fact that I do not initialize tmp_data, but I cannot know it's length.

    Read the article

  • jquery text area length count?

    - by Nimesh
    Hi All, I have a text area field where i need to provide information about the word count when the user enters some text in the field. Length of the field is supposed to be 500 Characters. Initialy it must show min characters:100 | 0 of 500 // 0 of 500 must be in red color and once the user enters come character need to update the count as well. Once the user reaches the count say the min character 100, i need to display min characters:100 | 100 of 500 // 100 of 500 must be in green color. How can i do this?? is there any plugin for the same??? let me know your thoughts on this.

    Read the article

  • Javascript Autocomplete Text

    - by WPS
    Hi All, I need to implement an autocomplete text field using JavaScript and JSF. When the user types some character in a text field, I need to make an AJAX request and get the values based on the values entered. I've an input text field, on "keyup" I'm triggering a function which submits the value to the server side. var timeoutid = 0; function intitiateTypeAhead(){ clearTimeout(timeoutid); if (document.getElementById("inputText").value.length >= 2) { timeoutid = setTimeout('clickButton', 500); } return false; } function clickButton(){ //submits the value to the server } <h:inputText id="inputText" onkeyup="intitiateTypeAhead()"></h:inputText> This works properly, but certain times the request is made for each character entered by the user. I'm not sure if there is anything wrong with the implementation. Can someone please help me to fix this?

    Read the article

  • How do you return a string from a function correctly in Dynamic C?

    - by aquanar
    I have a program I am trying to debug, but Dynamic C apparently treats strings differently than normal C does (well, character arrays, anyway). I have a function that I made to make an 8 character long (well, 10 to include the \0 ) string of 0s and 1s to show me the contents of an 8-bit char variable. (IE, I give it the number 13, it returns the string "0001101\0" ) When I use the code below, it prints out !{happy face] 6 times (well, the second one is the happy face alone for some reason), each return comes back as 0xDEAE or "!\x02. I thought it would dereference it and return the appropriate string, but it appears to just be sending the pointer and attempting to parse it. This may seem silly, but my experience was actually in C++ and Java, so going back to C brings up a few issues that were dealt with in later programming languages that I'm not entirely sure how to deal with (like the lack of string variables). How could I fix this code, or how would be a better way to do what I am trying to do (I thought maybe sending in a pointer to a character array and working on it from the function might work, but I thought I should ask to see if maybe I'm just trying to reinvent the wheel). Currently I have it set up like this: this is an excerpt from the main() display[0] = '\0'; for(i=0;i<6;i++) { sprintf(s, "%s ", *char_to_bits(buffer[i])); strcat(display, s); } DispStr(8,5, display); and this is the offending function: char *char_to_bits(char x) { char bits[16]; strcpy(bits,"00000000\0"); if (x & 0x01) bits[7]='1'; if (x & 0x02) bits[6]='1'; if (x & 0x04) bits[5]='1'; if (x & 0x08) bits[4]='1'; if (x & 0x10) bits[3]='1'; if (x & 0x20) bits[2]='1'; if (x & 0x40) bits[1]='1'; if (x & 0x80) bits[0]='1'; return bits; } and just for the sake of completion, the other function is used to output to the stdio window at a specific location: void DispStr(int x, int y, char *s) { x += 0x20; y += 0x20; printf ("\x1B=%c%c%s", x, y, s); }

    Read the article

  • [multiple issues] Customizing Xcode [fonts, code sense, and more]

    - by wwrob
    How can I make code completion case-sensitive? How can I make Ctrl-k kill the content of the line and the new line character? How can I make backspace always delete only one character, no matter what it is? Right now, it deletes spaces in chunks equal to my indent level. How to change the indentation style in file templates? I like to have the opening brace on its own line. How can I make the font aliased? EDIT: Issues 4 and 5 are solved. 1 through 3 are still open.

    Read the article

  • How do I change the Unit:Characters in Matlab?

    - by Jonas
    For portability, I set the units of my GUIs to 'characters'. Now I have a user who wants to use Matlab on his netbook, and the GUI window is larger than the screen (and thus cropped at the top). I think I could try and write something in the openingFcn of the GUI that measures screen size and then adjusts the GUI accordingly, but I'd rather avoid that, because I then need to deal with text that is bigger than the text boxes, etc. What I'd rather like to do is somehow adjust the unit 'character' on his Matlab installation. None of the font sizes in the preferences seem to have an effect on unit:character, though. Does anyone know whether there's a setting for that, which can be changed from within Matlab (I don't mind if it's something that is reset at every reboot, since I can just put it into the startup script)?

    Read the article

  • How can I replace ” with " in a mysql Query?

    - by vamsivanka
    I am trying to run this SQL from ASP.NET 2005 but am getting an invalid SQL error because it has a weird character ” in it. In my code I am trying to replace ” with " but it is not doing it as the special character in the replace command is changing to ". Query: insert into userquery(description) values ('In fact, Topeka Google Mayor Bill Bunten expressed it best: “Don’t be fooled. Even Google recognizes that all roads lead to Kansas, not just yellow brick ones.”') If I copy and execute this in mysql it is working good. How can I solve this problem?

    Read the article

  • xhtml validation javascript

    - by Jason
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> onmouseover="text.show('<br /><b>XXXXXX</b><br />')" Validation Output: Error: character "<" is the first character of a delimiter but occurred as data How can I fix it? thanks

    Read the article

  • is @font-face server dependant

    - by samquo
    Not sure if this has something to do the live host I'm working with, but I'm using @font-face in the following format, @font-face { font-family: 'UbuntuTitle'; src: url('Ubuntu-Title-webfont.eot'); src: local('?'), url('Ubuntu-Title-webfont.woff') format('woff'), url('Ubuntu-Title-webfont.ttf') format('truetype'), url('Ubuntu-Title-webfont.svg') format('svg'); font-weight: normal; font-style: normal; } I'm finding though that I can't save the document because of the strange character in () in local local('?') so I save it as UTF-8, but that changes the character to this local('☺'). Could that be the reason why it's not being picked up on the server? Any other possibilities?

    Read the article

  • Disallow typing of few of characters e.g.'<', '>' in all input textboxes using jquery

    - by Ismail
    How do I achieve this:- When user types character like 'abcd' and then '>'(an invalid character for my application), I want to set the text back to 'abcd'. Better if we can cancel the input itself as we do in winforms application. This should happen when user is typing and not on a click of button. I want this to be applied on all text boxes in my web page. This will be easy if the solution is jQuery based. May be something which will start like this. $("input[type='text']")

    Read the article

  • Safe ASCII char to replace whitespace before storing

    - by AngryWhenHungry
    My code passes a big bunch of text data to a legacy lib, which is responsible for storing it. However, it tends to remove trailing whitespace. This is a problem when I read the data back. Since I cannot change the legacy code, I thought about replacing the all spaces with some uncommon ASCII character. When I read back the text, I can replace them back. Is this a bad idea, considering that I cannot touch the legacy storage code? Which character can I use as a substitute? I was considering some char upwards of 180. There will only be spaces - no tabs or newlines - in the data. The data is alphanumeric, with special characters.

    Read the article

  • Best way to have unique key over 500M varchar(255) records in mysql/innodb?

    - by taw
    I have url column with unique key over it - but its performance on updates is absolutely atrocious. I suspect that's because the index doesn't all fit in memory. So I was thinking, how about adding a column of md5(url) with 16 bytes of binary data and unique-keying that instead. What would be the best datatype for that? I'd love to be able to just see 32-character hex hash, while mysql would convert it to/from 16 binary bytes and index that, as programs using the database might have some troubles with arbitrary binary data that I'd rather avoid if possible (also I'm a bit afraid that mysql might get some strange ideas about character sets and for example overalocating storage for that by 3:1 because it thinks it might need utf8, how do I avoid that for cure?).

    Read the article

  • Problem with joining to an empty table

    - by Imran Omar Bukhsh
    I use the following query: select * from A LEFT JOIN B on ( A.t_id != B.t_id) to get all the records in A that are not in B. The results are fine except when table B is completely empty, but then I do not get any records, even from table A. Later It wont work yet! CREATE TABLE IF NOT EXISTS T1 ( id int(11) unsigned NOT NULL AUTO_INCREMENT, title varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, t_id int(11) NOT NULL, PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; -- -- Dumping data for table T1 INSERT INTO T1 (id, title, t_id) VALUES (1, 'apple', 1), (2, 'orange', 2); -- -- Table structure for table T2 CREATE TABLE IF NOT EXISTS T2 ( id int(11) NOT NULL AUTO_INCREMENT, title varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, t_id int(11) NOT NULL, PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -- Dumping data for table T2 INSERT INTO T2 (id, title, t_id) VALUES (1, 'dad', 2); Now I want to get all records in T1 that do not have a corresponding records in T2 I try SELECT * FROM T1 LEFT OUTER JOIN T2 ON T1.t_id != T2.t_id and it won't work

    Read the article

  • How to optimize this script

    - by marks34
    I have written the following script. It opens a file, reads each line from it splitting by new line character and deleting first character in line. If line exists it's being added to array. Next each element of array is splitted by whitespace, sorted alphabetically and joined again. Every line is printed because script is fired from console and writes everything to file using standard output. I'd like to optimize this code to be more pythonic. Any ideas ? import sys def main(): filename = sys.argv[1] file = open(filename) arr = [] for line in file: line = line[1:].replace("\n", "") if line: arr.append(line) for line in arr: lines = line.split(" ") lines.sort(key=str.lower) line = ''.join(lines) print line if __name__ == '__main__': main()

    Read the article

  • preg_replace or regex string translation

    - by ccolon
    I found some partial help but cannot seem to fully accomplish what I need. I need to be able to do the following: I need an regular expression to replace any 1 to 3 character words between two words that are longer than 3 characters with a match any expression: For example: walk to the beach == walk(.*)beach If the 1 to 3 character word is not preceded by a word that's longer than 3 characters then I want to translate that 1 to 3 letter word to ' ?' For example: on the beach == on ?the ?beach The simpler the rule the better (of course, if there's an alternative more complicated version that's more performant then I'll take that as well as I eventually anticipate heavy usage eventually). This will be used in a PHP context most likely with preg_replace. Thus, if you can put it in that context then even better!

    Read the article

  • One on One table relation - is it harmful to keep relation in both tables?

    - by EBAGHAKI
    I have 2 tables that their rows have one on one relation.. For you to understand the situation, suppose there is one table with user informations and there is another table that contains a very specific informations and each user can only link to one these specific kind of informations ( suppose second table as characters ) And that character can only assign to the user who grabs it, Is it against the rules of designing clean databases to hold the relation key in both tables? User Table: user_id, name, age, character_id Character Table: character_id, shape, user_id I have to do it for performance, how do you think about it?

    Read the article

  • Print Data Frame with Columns Center Aligned in R

    - by Glen
    I would like to print a data frame where the columns are center aligned. Below is what I have I tried, I thought printing the data frame test1 would result in the columns being aligned in the center but this is not the case. Any thoughts on how I can do this? test=data.frame(x=c(1,2,3),y=c(5,6,7)) names(test)=c('Variable 1','Variable 2') test[,1]=as.character(test[,1]) test[,2]=as.character(test[,2]) test1=format(test,justify='centre') print(test,row.names=FALSE,quote=FALSE) Variable 1 Variable 2 1 5 2 6 3 7 print(test1,row.names=FALSE,quote=FALSE) Variable 1 Variable 2 1 5 2 6 3 7

    Read the article

  • How to specify comma , space unicode value in app.config(C#3.0)

    - by Newbie
    In the app.config file if I use <add key = "FileDelimeter" value ="&#2c;"/> as unicode for COMMA, it is throwing error Invalid character in a decimal number 'c' For SPACE, <add key = "FileDelimeter" value ="&#20;"/> the error is Character'', hex value 0*14 is illegal in xml while <add key = "FileDelimeter" value ="&#09;"/> for "\t" worked. Where is the mistake? Kindly give a generic solution. Thanks

    Read the article

< Previous Page | 75 76 77 78 79 80 81 82 83 84 85 86  | Next Page >