小编Jef*_*eff的帖子

如何在Java中转换HTML ==> RTF?

使用RTFEditorKit和HTMLEditorKit的JAVA的基本API无法识别像<br/>和的标签<table>.所以我在互联网上搜索了一种将HTML转换为RTF的更好方法,我找到了两种似乎有用的解决方案.JODConverter和HTML-to-RTFconverter.第一个需要安装OppenOffice才能工作,第二个需要使用DLL,所以它不能在Linux上使用.

有谁知道其他解决方案?

谢谢你的帮助!!!!

html java rtf

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

进行以下循环的更简洁方式?

我有以下for循环.它分别使用0-6形式的星期日 - 星期日.

是否有更简洁的方法来做到这一点?而不是列出来的if ($i=="day")

// $i = 0 is monday... $i = 6 is Sunday
for($i=0;$i<7;$i++){

    if ($i==0)
        echo ' <input name="repeat_on_week[]" type="checkbox" value="0"  /> Monday';
    if ($i==1)
        echo ' <input name="repeat_on_week[]" type="checkbox" value="1" /> Tuesday';
    if ($i==2)
        echo ' <input name="repeat_on_week[]" type="checkbox" value="2" /> Wednesday';
    if ($i==3)
       echo ' <input name="repeat_on_week[]" type="checkbox" value="3" /> Thursday';
    if ($i==4)
       echo ' <input name="repeat_on_week[]" type="checkbox" value="4" /> Friday';
    if ($i==5)
        echo ' <input name="repeat_on_week[]" type="checkbox" value="5" /> Saturday';
    if ($i==6) …
Run Code Online (Sandbox Code Playgroud)

php loops dayofweek

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

可能只根据Android操作系统版本加载特定的代码行?

是否有一行简单的代码只允许在OS版本满足要求时加载代码?

让我说我的目标操作系统为2.2,但是对于Android 1.5,min sdk为3,所以即使我的项目中有一些与1.5不兼容的代码,它仍然会编译,因为目标操作系统是2.2.无论如何,我想要广告一项功能,该功能需要不在1.5 SDK中的代码,并且如果它在1.5手机上加载会导致崩溃.有这么简单的事情,我可以做吗?所以我不必让1.5用户无法使用整个应用程序?

 if (Android OS == >2.1){
            //Insert code here that requires 2.1 and up}
        else{
            //insert code that would appear is OS is <2.1}
Run Code Online (Sandbox Code Playgroud)

java android android-1.5-cupcake

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

Java - 在网站中搜索数据

我是java新手并遇到一些问题.

主要思想是连接到一个网站并从中收集信息并将其存储在一个数组中.

我希望程序做的是搜索网站找到一个关键词,并存储关键词之后的内容.

在网站底部daniweb的首页上有一个名为"Tag Cloud"的部分,里面标有标签/短字

标签云:"我想存储这里写的东西"

我的想法是首先阅读网站的html,然后使用Scanner和StringTokenizer在该文件中搜索关键字后跟文本,然后存储为数组.

有更好的方式/更容易吗?

你在哪里建议我寻找一些例子

这是我到目前为止所拥有的.

import java.net.*;
import java.io.*;

public class URLReader {

    public static void main(String[] args) throws Exception {

        URL dweb = new URL("http://www.daniweb.com/");
        URLConnection dw = dweb.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(hc.getInputStream()));
        System.out.println("connected to daniweb");
        String inputLine;

        PrintStream out = new PrintStream(new FileOutputStream("OutFile.txt"));

        try {
        while ((inputLine = in.readLine()) != null)
            out.println(inputLine);

            //System.out.println(inputLine);
            //in.close();
        out.close();
        System.out.println("printed text to outfile");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

        try {
            Scanner scan = …
Run Code Online (Sandbox Code Playgroud)

java

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

用于WebSphere Portal开发的轻量级门户服务器?

我正在为IBM WebSphere Portal 6.1做一些portlet开发.但是,部署过程非常缓慢.由于这是我第一次进行portlet开发,所以我不太熟悉那里的各种门户服务器.我想为轻量级门户服务器提供一些建议,我可以在其上快速部署以进行开发.

java websphere portal websphere-portal

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

配置Rails以在开发和生产中使用不同的js

我希望Rails在开发和生产模式下注入不同的js文件.

例:

发展:

<script src="/javascripts/jquery.js" type="text/javascript"></script>
<script src="/javascripts/myscripts.js" type="text/javascript"></script>
Run Code Online (Sandbox Code Playgroud)

生产:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script src="/javascripts/myscripts.min.js" type="text/javascript"></script>
Run Code Online (Sandbox Code Playgroud)

是否有可能在Rails 3中实现它?

此致,Alexey Zakharov

javascript ruby-on-rails-3

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

Memcached总是想念(rails)

嗨Stackoverflowers,我在这个问题上花了太多时间来保持理智,所以是时候寻求帮助了...

我有一个使用此方法的类:

def telecom_info

    Rails.cache.fetch("telecom_info_for_#{ref_num}", :expires_in=> 3.hours) do
      info = Hash.new(0)
      Telecom::SERVICES.each do |source|
          results = TelecomUsage.find(:all, 
                                      :joins=>[:telecom_invoice=>{ :person=> :org_person}], 
                                      :conditions=>"dotted_ids like '%#{ref_num}%' and telecom_usages.ruby_type = '#{source}'", 
                                      :select=>"avg(charge) #{source.upcase}_AVG_CHARGE,
                                                max(charge) #{source.upcase}_MAX_CHARGE,
                                                min(charge) #{source.upcase}_MIN_CHARGE,
                                                sum(charge) #{source.upcase}_CHARGE,

                                                avg(volume) #{source.upcase}_AVG_VOLUME,
                                                max(volume) #{source.upcase}_MAX_VOLUME,
                                                min(volume) #{source.upcase}_MIN_VOLUME,
                                                sum(volume) #{source.upcase}_VOLUME
                                                ")

          results = results.first
          ['charge', 'volume'].each do |source_type|                                        
            info["#{source}_#{source_type}".to_sym] = results.send("#{source}_#{source_type}".downcase).to_i
            info["#{source}_min_#{source_type}".to_sym] = results.send("#{source}_min_#{source_type}".downcase).to_i
            info["#{source}_max_#{source_type}".to_sym] = results.send("#{source}_max_#{source_type}".downcase).to_i
            info["#{source}_avg_#{source_type}".to_sym] = results.send("#{source}_avg_#{source_type}".downcase).to_i
          end
      end

      return info
    end
end
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,这是一个昂贵的调用,每个请求都会调用ALOT,因此我想缓存它.问题是memcached似乎不起作用,在日志文件中,我得到:

缓存读取:telecom_info_for_60000000

缓存未命中:telecom_info_for_60000000({})

奇怪的是,我知道memcached正在工作,因为它确实缓存了我在另一个模型中的其他一些函数的结果.

有什么建议?我在REE 1.8.7上运行Rails 2.3.5

ruby memcached ruby-on-rails

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

在TreeMap中搜索(Java)

我需要在地图地图中搜索并返回此元素所属的键.我认为这个实现很慢,你能帮我优化一下吗?我需要使用TreeSet,我不能使用contains因为他们使用compareTo,而equals/compareTo对是以不兼容的方式实现的,我无法改变它.(抱歉,我的英文不好)

Map<Key, Map<SubKey, Set<Element>>> m = new TreeSet();

public String getKeys(Element element) { 
 for(Entry<Key, Map<SubKey, Set<Element>>> e : m.entrySet()) {
  mapSubKey = e.getValue();
  for(Entry<SubKey, Set<Element>> e2 : mapSubKey.entrySet()) {
   setElements = e2.getValue();
   for(Element elem : setElements)
    if(elem.equals(element)) return "Key: " + e.getKey() + " SubKey: " + e2.getKey();
  }
 }
}
Run Code Online (Sandbox Code Playgroud)

java treemap

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

PHP和欧元符号

让我们假设将以下字符串输入表单并提交给PHP脚本.

"€应编码为€"

我想知道如何实际将€编码为€ htmlentities()不会这样做,需要什么伏都教以便正确编码(以及其他喜欢它)?

php unicode

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

以下Java库代码如何退出while(true)循环?

我正在查看TimSort java代码: 在SourceLo函数的特定行676到739中的原始源代码.它(大致)有以下布局:

outer:
    while (true) {
        //Code here
        break outer; //Code within a few if tests in the loop.
    }
    //Code here executes somehow.
Run Code Online (Sandbox Code Playgroud)

我很困惑这个函数如何停止运行,因为唯一的break语句转到外部块(然后应该回到while(true),并且没有return语句.

我的问题是,当我尝试排序184个或更多元素时,第747行正在执行并抛出异常,我想弄清楚如何解决它,任何帮助都将非常感激.

[注意]:这是部署在Android手机上的Java的collections.sort方法调用的函数.

java logic while-loop

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

让md5变得强大

我正在制作一个网站,它将与仅支持md5哈希方法(atm)的游戏集成.哪个不再特别安全.但我怎么能让它更强大?我应该只生成长串的随机字母和数字并哈希吗?但是,用户必须将密码保存在计算机上的纸张/文本文件中.

你有什么建议?

security encryption hash md5

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