小编Gdg*_*ers的帖子

从Android手机上传文件到FTP服务器?

以下是创建文本文档并将其上传到我的FTP服务器的代码.由于某种原因,它似乎不起作用.我习惯了提供的图书馆

http://lavalatwork.blogspot.tw/2010/09/using-apache-commons-ftp-library-in.html

用于与FTP服务器通信.

try
    {
        final String testString = new String("Hello");
        FileOutputStream fOut = openFileOutput("samplefile.txt",
                MODE_WORLD_READABLE);
        OutputStreamWriter osw = new OutputStreamWriter(fOut); 

        osw.write(testString);
        osw.flush();
        osw.close();
    }


    catch(IOException ex)
    {

    }


    FTPClient mFTP = new FTPClient();
    try {
        // Connect to FTP Server
        mFTP.connect("192.168.10.101");
        //mFTP.login("user", "password");
        mFTP.setFileType(FTP.BINARY_FILE_TYPE);
        mFTP.enterLocalPassiveMode();

        // Prepare file to be uploaded to FTP Server
        File file = new File(getFileStreamPath("samplefile.txt")+ "");
        FileInputStream ifile = new FileInputStream(file);

        // Upload file to FTP Server
        mFTP.storeFile("filetotranfer",ifile);
        mFTP.disconnect();          
    } catch (SocketException e) {
        // …
Run Code Online (Sandbox Code Playgroud)

java ftp android apache-commons apache-commons-net

10
推荐指数
2
解决办法
5万
查看次数

FixedThreadPool和ThreadPoolTask​​Executor有什么区别?

使用以下配置配置线程池之间是否有区别:

Executors.newFixedThreadPool(50);
Run Code Online (Sandbox Code Playgroud)

与做:

ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(50);
executor.setThreadNamePrefix("thread-pool");
executor.initialize();
Run Code Online (Sandbox Code Playgroud)

我对在运行时配置线程池不感兴趣(我认为这是使用的主要驱动程序ThreadPoolTaskExecutor)。

java spring multithreading threadpool

8
推荐指数
2
解决办法
155
查看次数

Feign REST 客户端:如何获取 HTTP 状态?

我使用 Hystrix 设置了 Feign 客户端,并且尝试将从 API 调用中获得的所有 HTTP 状态代码记录到数据库中。所以这意味着,如果我的一个电话给我一个 201,我想把它记录到数据库中。如果我的调用导致失败,我的回退处理程序显然可以记录这一点,但我想在一个地方进行数据库插入。feign 是否有办法访问响应或某种一般回调?

rest hystrix feign

5
推荐指数
1
解决办法
5125
查看次数

使用正则表达式分隔单个单词?

我有以下行将句子分成单词并将其存储到基于空格的数组中: string[] s = Regex.Split(input, @"\s+");

问题是在句子结束时,它也会占用一段时间.例如:C# is cool.
代码将存储:

  1. C#
  2. is
  3. cool.

问题是:我如何才能不接受这段时间?

c# java regex string split

4
推荐指数
1
解决办法
2127
查看次数

USPS Tracking API预计交货日期?

我正在将USPS跟踪API集成到我当前的项目中,并需要一些帮助来获取所有跟踪信息.基本上,我的请求是通过以下URL完成的:

http://production.shippingapis.com/ShippingAPI.dll?API=TrackV2&XML=

此请求(一旦我输入正确的ID)返回包含摘要,跟踪ID和包位置的XML页面,但它没有关于预期交付日期的任何标记(使用的跟踪ID有一个).我的问题是如何获得显示在XML上的预期交付信息?我确信应该有办法获得这些信息,因为亚马逊和Ebay等其他公司都有"预期交付日期"以及所有跟踪信息.我尝试在API上阅读USPS手册(https://www.usps.com/business/web-tools-apis/track-and-confirm.pdf),但它并没有真正解释清楚.如果有人能理解它并帮助我,我会非常高兴.谢谢 !

xml api web-services usps

2
推荐指数
1
解决办法
2693
查看次数

为Unix系统转换Windows .cpp文件?

我有一个.cpp文件,我在Windows 8计算机上编写,我试图通过Putty SSH客户端将其代码粘贴到我的学校基于Unix的系统中.在Unix机器上使用的编辑器是Vi编辑器.当我从我的Windows计算机中的.cpp文件中复制所有代码并右键单击Vi编辑器并粘贴时,代码显示但它到处都是我甚至无法读取它(我很确定它不会' t编译).有没有办法解决它,以便代码在Vi编辑器中维护其格式?谢谢你的帮助 !

unix windows vi copy-paste

1
推荐指数
1
解决办法
185
查看次数

System.Printing未找到(C#)?

我试图从MSDN运行以下示例:

using System.Printing;

public class PrintTest {
public static void Main(string[] args)
{
    // Create the printer server and print queue objects
    LocalPrintServer localPrintServer = new LocalPrintServer();
    PrintQueue defaultPrintQueue = LocalPrintServer.GetDefaultPrintQueue();

    // Call AddJob
    PrintSystemJobInfo myPrintJob = defaultPrintQueue.AddJob();

    // Write a Byte buffer to the JobStream and close the stream
    Stream myStream = myPrintJob.JobStream;
    Byte[] myByteBuffer = UnicodeEncoding.Unicode.GetBytes("This is a test string for the print job stream.");
    myStream.Write(myByteBuffer, 0, myByteBuffer.Length);
    myStream.Close();
    }
}
Run Code Online (Sandbox Code Playgroud)

但编译器抱怨

命名空间系统中不存在类型或命名空间打印(您是否缺少程序集引用)?

我该如何解决这个问题?

编辑:如何为命令行编译的应用程序(非Visual Studio)添加引用

c# printing dll

1
推荐指数
2
解决办法
7967
查看次数

Java/Springboot:在一处捕获并处理特定异常?

是否有可能在整个 Spring Boot 应用程序中捕获特定类型的所有抛出异常(例如 IllegalArgumentException)并在一个地方处理它?我想为应用程序中的特定类型的异常引入一些额外的日志记录,并且我正在寻找一种方法来避免在整个应用程序中重复逻辑或方法调用?

java spring-boot

1
推荐指数
1
解决办法
1612
查看次数