本篇文章给大家谈谈callcenterjava,以及对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
1、java FTP怎么上传文件2、本人想编写一个JAVA与电话连接的程序求指点3、在andorid 出现 java.lang.UnsupportedOperationException4、请java 发送Http请求,后返回的值少了,第一个字符,是什么原因?请各位大虾帮帮忙
java FTP怎么上传文件
上传下载的代码
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import sun.net.TelnetOutputStream;
import sun.net.TelnetInputStream;
import sun.net.;
public class download {
String localfilename;
String remotefilename;
FtpClient ftpClient;
// server:服务器名字
// user:用户名
// password:密码
// path:服务器上的路径
public void connectServer(String ip, int port,String user
, String password,String path) {
try {
ftpClient = new FtpClient();
ftpClient.openServer(ip,port);
ftpClient.login(user, password);
System.out.println(“login success!”);
if (path.length() != 0) ftpClient.cd(path);
ftpClient.binary();
} catch (IOException ex) {
System.out.println(“not login”);
System.out.println(ex);
}
}
public void closeConnect() {
try {
ftpClient.closeServer();
System.out.println(“disconnect success”);
} catch (IOException ex) {
System.out.println(“not disconnect”);
System.out.println(ex);
}
}
public void upload() {
this.localfilename = “D://test2//test.txt”;
this.remotefilename = “test.txt”;
try {
TelnetOutputStream os = ftpClient.put(this.remotefilename);
java.io.File file_in = new java.io.File(this.localfilename);
FileInputStream is = new FileInputStream(file_in);
byte[] bytes = new byte[1024];
int c;
while ((c = is.read(bytes)) != -1) {
os.write(bytes, 0, c);
}
System.out.println(“upload success”);
is.close();
os.close();
} catch (IOException ex) {
System.out.println(“not upload”);
System.out.println(ex);
}
}
public void download() {
try {
TelnetInputStream is = ftpClient.get(this.remotefilename);
java.io.File file_in = new java.io.File(this.localfilename);
FileOutputStream os = new FileOutputStream(file_in);
byte[] bytes = new byte[1024];
int c;
while ((c = is.read(bytes)) != -1) {
// System.out.println((char)is.read());
// System.out.println(file_in);
os.write(bytes, 0, c);
}
System.out.println(“download success”);
os.close();
is.close();
} catch (IOException ex) {
System.out.println(“not download”);
System.out.println(ex);
}
}
public void download(String remotePath,String remoteFile,String localFile) {
try {
if (remotePath.length() != 0) ftpClient.cd(remotePath);
TelnetInputStream is = ftpClient.get(remoteFile);
java.io.File file_in = new java.io.File(localFile);
FileOutputStream os = new FileOutputStream(file_in);
byte[] bytes = new byte[1024];
int c;
while ((c = is.read(bytes)) != -1) {
// System.out.println((char)is.read());
// System.out.println(file_in);
os.write(bytes, 0, c);
}
System.out.println(“download success”);
os.close();
is.close();
} catch (IOException ex) {
System.out.println(“not download”);
System.out.println(ex);
}
}
public void download(String remoteFile,String localFile) {
try {
TelnetInputStream is = ftpClient.get(remoteFile);
java.io.File file_in = new java.io.File(localFile);
FileOutputStream os = new FileOutputStream(file_in);
byte[] bytes = new byte[1024];
int c;
while ((c = is.read(bytes)) != -1) {
// System.out.println((char)is.read());
// System.out.println(file_in);
os.write(bytes, 0, c);
}
System.out.println(“download success”);
os.close();
is.close();
} catch (IOException ex) {
System.out.println(“not download”);
System.out.println(ex);
}
}
public static void main(String agrs[]) {
String filepath[] = { “/callcenter/index.jsp”, “/callcenter/ip.txt”,
“/callcenter/mainframe/image/processing_bar_2.gif”,
“/callcenter/mainframe/image/logo_01.jpg” };
String localfilepath[] = { “C:\\FTP_Test\\index.jsp”,
“C:\\FTP_Test\\ip.txt”, “C:\\FTP_Test\\processing_bar_2.gif”,
“C:\\FTP_Test\\logo_01.jpg” };
download fu = new download();
fu.connectServer(“172.16.1.66”,22, “web_test”, “123456”,”/callcenter”);
for(int i=0;ifilepath.length;i++){
fu.download(filepath[i],localfilepath[i]);
}
//fu.upload();
//fu.download();
fu.closeConnect();
}
}
本人想编写一个JAVA与电话连接的程序求指点
兄弟.我建议你先搞清楚现有ivr的架构.
1。据我做过的ivr的了解.现在大都是web实现,至于你说看不到浏览器窗口.可能只是把工具栏隐藏.或者直接在外层做了包装,这个很简单.
2.电话和电脑要连接需要语音卡或者交换机.
3.要做web,j2ee的知识是少不了的.
4.我觉得你现在需要了解的是系统构成.还有把基础打好.急于实现一些你现在实现不了的东西,只会给你打击.
在andorid 出现 java.lang.UnsupportedOperationException
关键字: java集合中部分异常java.lang.unsupportedoperationexception一个共同点
在项目中采用一个枚举的集合,本人采用Collections中的空集合Collections.emptyList()在添加时发生异常:
常见集合如下:
private ListVacationCategory vacationcategorys = Collections.emptyList();
报错误如下:
— Encapsulated exception ————\
java.lang.UnsupportedOperationException
at java.util.AbstractList.add(AbstractList.java:131)
at java.util.AbstractList.add(AbstractList.java:91)
at com.unutrip.callcenter.vacation.web.condition.VacationOrderConditionConvertor.setProductStyle(VacationOrderConditionConvertor.java:155)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
…………………………
JDK API解释如下:
java.lang.CloneNotSupportedException
不支持克隆异常。当没有实现Cloneable接口或者不支持克隆方法时,调用其clone()方法则抛出该异常。
在网上查一下原因是因为部分集合类型一样但是缺少部分方法或不支持。
如特殊情况如下:
(1)常常使用Arrays.asLisvt()后调用add,remove这些method时出现java.lang.UnsupportedOperationException异常。这是由于:
Arrays.asLisvt() 返回java.util.Arrays$ArrayList, 而不是ArrayList。Arrays$ArrayList和ArrayList都是继承AbstractList,remove,add等method在AbstractList中是默认throw UnsupportedOperationException而且不作任何操作。ArrayList override这些method来对list进行操作,但是Arrays$ArrayList没有override remove(int),add(int)等,所以throw UnsupportedOperationException。
解决方法是使用Iterator,或者转换为ArrayList
List list = Arrays.asList(a[]);
List arrayList = new ArrayList(list);
(2)
private ListVacationCategory vacationcategorys = Collections.emptyList();
执行remove,add等method时,抛出此异常,本人将上述代码改为:
private ListVacationCategory vacationcategorys = new ArrayListVacationCategory();
没有此错误,于是我查看一下源代码:
源码如下:
此类在Collections的类中:
/**
* The empty list (immutable). This list is serializable.
*
* @see #emptyList()
*/
public static final List EMPTY_LIST = new EmptyList();
/**
* Returns the empty list (immutable). This list is serializable.
*
* pThis example illustrates the type-safe way to obtain an empty list:
* pre
* ListString s = Collections.emptyList();
* /pre
* Implementation note: Implementations of this method need not
* create a separate ttList/tt object for each call. Using this
* method is likely to have comparable cost to using the like-named
* field. (Unlike this method, the field does not provide type safety.)
*
* @see #EMPTY_LIST
* @since 1.5
*/
public static final T ListT emptyList() {
return (ListT) EMPTY_LIST;
}
/**
* @serial include
*/
private static class EmptyList
extends AbstractListObject
implements RandomAccess, Serializable {
// use serialVersionUID from JDK 1.2.2 for interoperability
private static final long serialVersionUID = 8842843931221139166L;
public int size() {return 0;}
public boolean contains(Object obj) {return false;}
public Object get(int index) {
throw new IndexOutOfBoundsException(“Index: “+index);
}
// Preserves singleton property
private Object readResolve() {
return EMPTY_LIST;
}
}
EmptyList此集合竟然没有相应的add,remove等方法,哭了,呜呜………..
~~~~(_)~~~~
请java 发送Http请求,后返回的值少了,第一个字符,是什么原因?请各位大虾帮帮忙
// rd.reset();
while(rd.read()!=-1){
temp.append(rd.readLine());
}
问题就出在你的rd.read()上,你调用了一次read(),就会从底层的二进制流中读取一个byte出来,而“1”这个字符不论什么编码,都是只用一个byte表示,所以会丢了一个1。
正确的作法是这样:
String respStr = null;
while ( (respStr = rd.readLine() ) != null ) {
temp.append(respStr);
}
callcenterjava的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于、callcenterjava的信息别忘了在本站进行查找喔。