[Solved] How to sort numeric value in file

To read a file of “lines” in Java you can use the Files class like this: final List<String> l = Files.readAllLines(Paths.get(“/some/path/input.txt”)); This reads a file and stores each line in a List. When you have the List of String objects you can use a simple Comparator and the Collections.sortmethod. Check this code out: final List<String> … Read more

[Solved] If html page doesn’t have the special links, then give an alert with Javascript

It depends on how you write your html. Assuming the footer element is always there: if (document.getElementById(‘footer’).childNodes.length == 0) { //If function find the copyright links, then null – don’t make anything } else //If function doesn’t find copyright links, then give an alert alert(“Please protect original copyright links.”) but remember, this just counts what … Read more

[Solved] Replace Function – vb.net [closed]

don’n know exactly what do you want but below 2 code snippets can help you: 1.just use Replace: ‘remove tab characters Dim outString as String = inString.Replace(Constants.vbTab, “”) or ‘remove spacec haracters Dim outString as String = inString.Replace(” “, “”) 2.use an Split then use Replace in a loop through resulted array by Split: ‘split … Read more

[Solved] snake game: snake colliding with itself

In your code it looks as though you are checking if the head of the snake collide with itself, which will always return True. You need to individually check that the head of snake does not collide with any of it’s trailing segments: for segment in SnakeSegments[2:]: if pygame.sprite.collide_rect(h, segment): pass # collision detected, game-over … Read more

[Solved] In Java, how can I get a variable to print two doubles separately instead of adding them?

You just need to print the number as a string. replace outputDegreesF() with public static void outputDegreesF(double degreesC) { double fahrenheit = 32.0 + (degreesC * 9.0 / 5.0); System.out.print(degreesC + ” ” + fahrenheit); // Easier // Or System.out.printf(“%.7f %.7f”, degreesC, fahrenheit); // Used more and lets you format } If you want to … Read more

[Solved] File input output in c

the correct way is: int myreadfile(void) { FILE *fp; int i, n; unsigned char a[50]; if (!(fp=fopen(“x.exe”,”rb”))) return(0); while(n=fread(a,1,sizeof(a), fp)) { for (i=0; i<n; i++) printf(“%02x “,a[i]); printf(“\n”); } fclose(fp); return 1; } Note that the buffer is of type unsigned char. That is because a) you don’t know if the file is a complete … Read more

[Solved] C++ dynamic way to determine the container to use

You seem to be getting an awful lot of different concepts confused, certainly more than could be sorted out in this form. One way to solve this would be a base class Product from which all your various “product types” derive, solving your first bullet point neatly, as any standard container could hold various types … Read more

[Solved] Spring Mvc method argumrnts

This is basic Java and has nothing to do with Spring. Local variables and method parameters are initialized differently. For a method parameter the initialization is implicit because you must give some value to the method call. Example: // Declaration public String showForm(Model theModel) { } // Call showForm(null); You cannot ommit the argument and … Read more

[Solved] Unable to get data from Sql Server 2005 (connection time out exception)

As the jTDS FAQ states, the URL must be in the form jdbc:jtds:<server_type>://<server>[:<port>][/<database>][;<property>=<value>[;…]] Infering from your connection: mindmill is the name of your_computer/server where Sql Server 2005 is installed. 1433 is the (default) port to connect with Sql Server 2005. employ is the database name. mahesh is your user and password to connect to server. … Read more