-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
working now, added seperate classes for sending data
- Loading branch information
1 parent
79c4d2d
commit 0ee899a
Showing
12 changed files
with
162 additions
and
58 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package javacode; | ||
import java.io.BufferedReader; | ||
import java.io.InputStreamReader; | ||
import java.io.OutputStreamWriter; | ||
import java.net.InetAddress; | ||
import java.net.Socket; | ||
import java.util.ArrayList; | ||
|
||
public class sendphrase { | ||
private ArrayList <String> phrase = new ArrayList <String> (); | ||
private String result; | ||
|
||
public sendphrase() { | ||
this.phrase = null; | ||
this.result = ""; | ||
} | ||
|
||
public sendphrase(ArrayList <String> phrase) { | ||
try { | ||
InetAddress localhost = InetAddress.getByName("localhost"); | ||
Socket s = new Socket(localhost, 9000); | ||
OutputStreamWriter out = new OutputStreamWriter(s.getOutputStream()); | ||
BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream())); | ||
//sending phrase | ||
for (String word : phrase) { | ||
out.write(word); | ||
} | ||
out.flush(); | ||
|
||
//getting result | ||
String result = in.readLine(); | ||
this.result = result; | ||
|
||
} catch (Exception e) { | ||
System.err.println("Connection Error"); | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public void setPhrase(ArrayList <String> phrase) { | ||
this.phrase = phrase; | ||
} | ||
|
||
public String getResult() { | ||
return this.result; | ||
} | ||
|
||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#BlueJ class context | ||
comment0.target=sendword | ||
comment1.params= | ||
comment1.target=sendword() | ||
comment2.params=word | ||
comment2.target=sendword(java.lang.String) | ||
comment3.params=word | ||
comment3.target=void\ setWord(java.lang.String) | ||
comment4.params= | ||
comment4.target=java.lang.String\ getResult() | ||
numComments=5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package javacode; | ||
import java.io.IOException; | ||
import java.io.BufferedReader; | ||
import java.io.InputStreamReader; | ||
import java.io.OutputStreamWriter; | ||
import java.net.InetAddress; | ||
import java.net.Socket; | ||
|
||
public class sendword { | ||
private String word; | ||
private String result; | ||
|
||
public sendword() { | ||
this.word = ""; | ||
this.result = ""; | ||
} | ||
|
||
|
||
public sendword(String word) { | ||
try { | ||
InetAddress localhost = InetAddress.getByName("localhost"); | ||
Socket s = new Socket(localhost, 9000); | ||
OutputStreamWriter out = new OutputStreamWriter(s.getOutputStream()); | ||
BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream())); | ||
//sending word | ||
out.write(word); | ||
out.flush(); | ||
|
||
//getting result | ||
String result = in.readLine(); | ||
this.result = result; | ||
|
||
} catch (Exception e) { | ||
System.err.println("Connection Error"); | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public void setWord(String word) { | ||
this.word = word; | ||
} | ||
|
||
public String getResult() { | ||
return this.result; | ||
} | ||
|
||
} | ||
|