当前位置: 技术问答>java相关
五星“急”问题之一:java与vb互发信息,请多指教
来源: 互联网 发布时间:2015-02-13
本文导语: 我做的程序要用VB来编写界面,用Socket与VB利用TCP连接正常,但不知道如何发送信息? 发送的信息是用的流形式(OutputStream,InputSteam),在java机器之间可以实现,但与VB写的服务器程序只能连接,不能通信,怎么办?急...
我做的程序要用VB来编写界面,用Socket与VB利用TCP连接正常,但不知道如何发送信息?
发送的信息是用的流形式(OutputStream,InputSteam),在java机器之间可以实现,但与VB写的服务器程序只能连接,不能通信,怎么办?急!!!!
发送的信息是用的流形式(OutputStream,InputSteam),在java机器之间可以实现,但与VB写的服务器程序只能连接,不能通信,怎么办?急!!!!
|
我是用OutputStreamWriter,InputStreamReader来作的。
IOutputStreamWriter.java
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.OutputStreamWriter;
/**
* Title: SMS Simulate
* Description: This is a test program that simulate a simple SMS system.
* Copyright: Copyright (c) 2001
* Company:
* @author lusxiao
* @version 1.0
*/
public class IOutputStreamWriter extends OutputStreamWriter {
public IOutputStreamWriter(OutputStream os) {
super(os);
}
public void write(String str, int off, int len) throws java.io.IOException {
char c[]=new char[len];
int clen=(len>str.length())?str.length():len;
str.getChars(0,clen,c,0);
super.write( c, off, len);
}
}
IInputStreamReader.java
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
/**
* Title: SMS Simulate
* Description: This is a test program that simulate a simple SMS system.
* Copyright: Copyright (c) 2001
* Company:
* @author lusxiao
* @version 1.0
*/
public class IInputStreamReader extends InputStreamReader {
public IInputStreamReader(InputStream is){
super(is);
}
public String read(int offset,int length) throws IOException{
char c[]=new char[length];
read(c,0,length);
return new String(c).trim();
}
}
服务器端c的例子找不到了。
IOutputStreamWriter.java
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.OutputStreamWriter;
/**
* Title: SMS Simulate
* Description: This is a test program that simulate a simple SMS system.
* Copyright: Copyright (c) 2001
* Company:
* @author lusxiao
* @version 1.0
*/
public class IOutputStreamWriter extends OutputStreamWriter {
public IOutputStreamWriter(OutputStream os) {
super(os);
}
public void write(String str, int off, int len) throws java.io.IOException {
char c[]=new char[len];
int clen=(len>str.length())?str.length():len;
str.getChars(0,clen,c,0);
super.write( c, off, len);
}
}
IInputStreamReader.java
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
/**
* Title: SMS Simulate
* Description: This is a test program that simulate a simple SMS system.
* Copyright: Copyright (c) 2001
* Company:
* @author lusxiao
* @version 1.0
*/
public class IInputStreamReader extends InputStreamReader {
public IInputStreamReader(InputStream is){
super(is);
}
public String read(int offset,int length) throws IOException{
char c[]=new char[length];
read(c,0,length);
return new String(c).trim();
}
}
服务器端c的例子找不到了。