📄 hylafaxclient.java
字号:
/*
* JTAPI library copyright 1998 by Web4Groups consortium (http://Web4Groups.at)
*/
import java.util.*;
import java.io.*;
import java.net.*;
public class HylafaxClient {
String serverHost;
int serverPort;
String command;
String fileName;
String faxNr;
public HylafaxClient(String serverHost,int serverPort, String command, String faxNr, String fileName) {
this.serverHost = serverHost;
this.serverPort = serverPort;
this.command = command;
this.fileName = fileName;
this.faxNr = faxNr;
}
public boolean send() {
try {
Socket s = new Socket(serverHost, serverPort);
OutputStream out = s.getOutputStream();
File f = new File(fileName);
long length = f.length();
FileInputStream in = new FileInputStream(f);
byte buf[] = new byte[16584];
int r;
System.out.println("Should send: " + length);
String header = "" + length + "\n";
out.write(header.getBytes());
String cmd = "" + command + "\n";
out.write(cmd.getBytes());
String dest = "" + faxNr + "\n";
out.write(dest.getBytes());
do {
r = in.read(buf,0,16584);
if(r>0)
out.write(buf,0,r);
}while(r != -1);
s.close();
}
catch(Exception exc) {
System.out.println("Exception catched");
exc.printStackTrace();
return false;
}
return true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -