|
from socket import * #Start test() def test(): #Specify the port serverPort = 80 serverSocket = socket(AF_INET,SOCK_STREAM) serverSocket.bind(('',serverPort)) #Listen for the 1 connection serverSocket.listen(1) #Print the port address print("web server on port",serverPort) #Start thw while loop. while True: #Establish the connection. print("ready to serve") #Create connection socket for accepted client. connectionSocket,addr = serverSocket.accept() #Start the try block. try: #Recieve message. message = connectionSocket.recv(1024) #Print the connection message print(message) #Determine the filename filename = message.split()[1] #Print the file name print(filename[1]) print(filename,'||',filename[1]) #Open the file f = open(filename[1:]) outputdata = f.read() #DEBUG to check output data print(outputdata) #Send one HTTP header line … |
0
6
|
||
|
when I read FutureTask's run method, I found it use cas to set runner variable, public void run() { if (state != NEW || !UNSAFE.compareAndSwapObject(this, runnerOffset, null, Thread.currentThread())) return; try { Callable<V> c = callable; if (c != null && state == NEW) { V result; boolean ran; try { result = c.call(); ran = true; } catch (Throwable ex) { result = null; ran = false; setException(ex); } if (ran) set(result); } Future can be used for executor to submit a task,the code like this: Future<Integer> futureTask1 = executor.submit(callable) in submit method, it will new FutureTask,`RunnableFuture<T> ftask = newTaskFor(task)`, … |
0
20
|
||
|
Rick is really fond of fruit juices, but he is bored of their traditional flavours. Therefore, he has decided to mix as many of them as possible to obtain something entirely new as a result. He has N glasses, numbered from 0 to N-1, each containing a different kind of juice. The J-th glass has capacity[J] units of capacity and contains juice[J] units of juice. In each glass there is at least one unit of juice. Rick want to create a multivitamin mix in one of the glasses. He is going to do it by pouring juice from several other … |
0
94
|
||
|
hi there i have some python coding which i need to convert to java can ne1 help me please email me back if you can help then i will show you the coding much appriciated |
0
43,836
|
||
|
hi there i have an XML file wich contain some music information in a node and i would like to insert more i would like to add more node on demeand when i do i receive this error HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted. here is my XML structure ?xml version="1.0" encoding="UTF-8" standalone="no"?> <playlist> <trackList> <track id="1"> <location>C:\Music\subfoder\title.mp3</location> <creator>2Pac</creator> <title>Young Black Male</title> <album>2Pacalypse Now</album> </track> <--I WOULD LIE TO INSERT another node here track id ="2" --> </trackList> <--IN MANY THINGS I TESTED SOME INSERTED NODE HERE AND IT'S NOT WHAT I … |
0
34
|
||
|
Sir I have installed JAVA 15 windows 7 64bit  I want to ask what Microsoft JDBC Driver for SQLSERVER 2014 should I download. Please |
0
41
|
||
|
HELP ME IN MY BUS RESERVATION PROJECT I NEED TO HAVE A CONDITONAL STATEMENT IN MT SEATING ARRANGEMENT FOR EXAMPLE IF THE SEAT NUMBER IS ALREADY SELECTED IT WILL POP UP THE SEAT IS ALREADY SELECTED I USE THE COMBO BOX FOR THE SEAT NUMBER |
0
163
|
||
|
I am a final year student. Now I need to start work for final project. But I am not familiar how to do it. Can you help me out, How to prepare a index page for my website ( Complaint website). Or if you have completed project before, Please send me the index page. Thanks. |
0
29
|
||
|
Hello all, I am fairly new to Java, and have had a terrible time with arrays thus far. I am attempting to complete a project using arrays to store inventory items (item number, name, unit price, and unit numbers) and need to output information using an array to hold the information. Another requirement for class is using a subclass to hold one more unique feature to the program and calculating an additional .05% increase on the total for output on all items. I have so far built the array, class to set/get item information and also a calculation to calculate … |
0
491
|
||
|
What's the best cloud accounting software for small businesses that handle multiple sales tax rates? Or is there an affordable web-based small business accounting software? |
1
98
|
||
|
I played many games but none of them were soo good, but then i found sims4 and i'm playing it from last 1 year andi also want to know how can i make a better game than this with some more functions and updates. I found a [website ](www.sims4studiodownload.com/unlock-all-items)which tell everything about sims4, check it out and tell me how can i make a good game like this. |
-1
63
|
||
|
How can read line in file that line have recordor examplethe file: date new_cases new_deaths 2020-07-30 665 10 2020-07-31 590 9 2020-08-01 - 0 2020-08-02 - - 2020-06-04 738 8 2020-06-05 779 - 2020-06-06 770 5 4 line it is not record new_cases or new_deaths so wae ignore the line also line 5 but line 6 we read because it has record> after read this file the reasult is: 2020-07-30 665 10 2020-07-31 590 9 2020-06-04 738 8 2020-06-06 770 5 How can read read this line by java???? |
0
30
|
||
|
Hi everyone, I just want to ask if how i am able to make an if else statement inside a switch case. i want to execute something wherein the user may be able to choose again if he/she would like to do another transaction. for example, the user choose Yes the program will automatically display the main menu option and if the user doesn't want another the program will automatically print "Thankyou for using the program" |
0
150
|
||
|
I came across a KMeans implementation in Java. The number of clusters generated by the code is 3. But when I tried to change it to 2, I am getting the error: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2 Any help is much appreciated. Here is the code: public class KMeans { public static void main(String[] args) { int data[] = {2,4,10,12,3,20,30,11, 12, 14, 19, 21, 29, 31, 40};//,25,17,23}; // initial data int noofclusters = 2; int centroid[][]=new int[][]{ {0,0,0}, {2,4,30} }; getCentroid(data,noofclusters,centroid); }//main public static int[][] getCentroid(int data[],int noofclusters,int centroid[][]){ int distance[][]=new int[noofclusters][data.length]; int cluster[]=new int[data.length]; int clusternodecount[]=new int[noofclusters]; centroid[0]=centroid[1]; … |
0
52
|
||
|
this is what i have so far. public class PersonalInformation{ /* =================================================== ===== Challenge 6.1 - Personal Information Class ===== ====================================================== Design a class that holds the following personal data: name, age, and phone number. Write appropriate accessor and mutator methods. Demonstrate the class by writing a program that creates three instances of it. One instance should hold your information, and the other two should hold your friends' or family member's information. */ public static void main(String[] args) { // Create the objects. // Set my info. PersonalInformation myInfo = new PersonalInformation(); name startName = new name("Joe Mahoney"); startAddress.setAddress("724 22nd … |
0
84
|
||
|
Need help with two classes "Cannonball Component" and "Cannonball" I couldn't figure out the code with the rest but. Feel free to look at code check : http://codecheck.it/codecheck/files?repo=bj4fp&problem=ch06/c06_exp_6_16 |
1
42
|
||
|
How will you guide student?? |
0
60
|
||
|
Hi i'm a beginner in Java. I have school assigment where they want to save employee array to the file and can load it back with replacing the current array in GUI when it hit button save or load. Also, if i want to save or load the array with the specific file name from JTextField what code should i include. import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.awt.event.ActionListener; import java.io.FileOutputStream; import java.util.Scanner; import java.awt.event.ActionEvent; import java.io.*; import javax.swing.JOptionPane; public class Etracker { public static void main(String[] args) { Etracker etk = new Etracker(); Etracker file = new Etracker(); etk.getInput(); … |
2
89
|
||
|
I 'm building an application to store and retrieve books, but I have an issue with retrieving data from the db. I'm using REST and testing with postman. Everything works OK. Currently I have a series of methods written in Java at the backend like so @Override @POST @Path("/add") //@Produces("application/json") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public Response addBook(Book book) { dbAccess.connectToDb(); return dbAccess.addBook(book); } @Override @DELETE @Path("/{id}/delete") @Produces("application/json") public Response deleteBook(@PathParam("id") int id) { dbAccess.connectToDb(); return dbAccess.deleteBook(id); } @Override @GET @Path("/{id}/get") @Produces("application/json") public Book getBook(@PathParam("id") int id) { dbAccess.connectToDb(); return dbAccess.getBook(id); } So in postman I have a request like http://localhost:8080/book-storage-REST/book/15/get to retrieve … |
0
321
|
||
|
Write a Java application that calculates the number of repayments for a loan based on the initial loan amount, annual interest rate and monthly payment. The user enters these values and application uses a loop to display the balance each month after payment has been made. Note that interest is charged each month on the remaining balance. For this exercise, you need to use a while loop that repeats as long as the balance is greater than zero to calculate the new balance with interest after each payment. The body of the loop calculates the new balance plus monthly interest … |
0
1,309
|
||
|
Heres an example since A is a square matrix while B and C is not. The program on my head is a row and a colum counter then if the row and colum is equal to eachother then the system will print out that the A matrix is a square matrix and both B and C are not. Is their efficent way on doing this? {7, 2, 1}, A = {0, 4, 2}, {5, 7,11} {1 }, C = {2, 3, 4}, {5, 6 } {1, 4}, B = {2, 8}, {1, 6,} |
0
26
|
||
|
JQ is taking a car trip with his family. On the trip, he will stop for fuel, food or lodging. When stopping for gas, JQ will record the amount of fuel he is willing to pay for. When the family stops for lodging, they will also have a meal. JQ is only willing to spend a maximum of $75 on accommodation. If the motel manager says the price is greater than $75, JQ will complain “We will look elsewhere”. If the charge is less or equal to $75, he will pay the amount and exclaim “Wonderful, we will stay!” JQ … |
0
62
|
||
|
I have an existing text file with a list of book names. I want to read those names & write a second text file with the names of duplicate entries. For example: SamsBookstore.txt might have And Then It's Spring Baby Bear Sees Blue Beach Feet Jimmy the Greatest! Boot & Shoe Baby Bear Sees Blue Boy & Bot Cat Tale Creepy Carrots! Jimmy the Greatest! I would want the SamsDuplicates.txt to have: Baby Bear Sees Blue Jimmy the Greatest! I already have some of this code, but i'm not sure if its common to post it in the thread or … |
0
30
|
||
|
hello can anybody help me with this issue i have java code to print information that exists in XML file i will paste it here, so i want to print the information based on user input , as example the user enter the Id number then the program should print all information relative to that Id so my java code is : package parse; import java.io.File; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Parse { public static void main(String[] args) { try{ File inputFile = new File("C:\\Users\\Abdal\\Documents\\NetBeansProjects\\Creation\\user_info.xml"); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); // this … |
0
40
|
||
|
How can i make codes for this? Problems for Program Development 1. Create a java program that will display a menu for choices to perform the following routines: 1. Input a number then determine and display the factors of the number. 2. Input a number then determine and display if the number is odd or even. 3. Input a number then determine and display if the number is a Perfect Number or Not. 4. Input the elements of a 1-dimensional array using the Random Class (random elements from 0 to 9 and random size from 0 to 10) then display … |
0
33
|
||
|
I want this kind of output How? output: Enter a number: 3456 Digit(s): 3 4 5 6 |
0
23
|
||
|
Hiii How are you every one im very happy to be here with all of you & i hopeto enjoy our time togather Thanks :) |
2
47
|
||
|
import random money = 100 Ask user if they want to play or "QUIT" (.upper()) while game != "QUIT": 2 dice generate random numbers 1-6 on each (generate random numbers inside while loop) Every roll cost $3 Win $5 if total is 7 Win $10 for snake eyes Else display " Craps" Ask user if they want to play or "QUIT" if money<3 game ="QUIT" Print money |
0
50
|
||
|
What are the top learning management systems for corporations? And how it helps for employee training? |
0
26
|
||
|
Hey guys I'm having trouble figuring out how to calculate the standard divination of an array in Java. As you can see I have already calculated the mean, and I know that at the end I will have to divide by the sample size minus 1 (n-1) and square that number. The problem I'm having is how to take every number and calculate how far it is away from the mean, then square that number. I know I could do every number from the data set separately but there has to be an easier way. Any help would be appreciated, … |
0
16,553
|
The End.