小编San*_*eep的帖子

在java中编写文本文件的最简单方法是什么?

您好,我想知道在java中编写文本文件最简单(也是最简单)的方法是什么.请简单,因为我是初学者:D我在网上搜索并找到了这段代码,但我理解了50%的代码.

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class WriteToFileExample {
public static void main(String[] args) {
    try {

        String content = "This is the content to write into file";

        File file = new  File("C:/Users/Geroge/SkyDrive/Documents/inputFile.txt");

        // if file doesnt exists, then create it
        if (!file.exists()) {
            file.createNewFile();
        }

        FileWriter fw = new FileWriter(file.getAbsoluteFile());
        BufferedWriter bw = new BufferedWriter(fw);
        bw.write(content);
        bw.close();

        System.out.println("Done");

    } catch (IOException e) {
        e.printStackTrace();
    }
}
Run Code Online (Sandbox Code Playgroud)

}

java text file

34
推荐指数
4
解决办法
6万
查看次数

Apache proxypass 不解析图像和 css 等资源的 url

我需要将路径映射到我的 tomcat Web 应用程序。我为此使用了代理通行证。这是 apache2 中的当前配置

<VirtualHost *:80>
        ServerName localhost:80
        ProxyPass /app http://localhost:8088/ui/
        ProxyPassReverse /app http://localhost:8088/ui/


        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

这从 tomcat 获取 HTML,但形成的 css url 是错误的。而不是http://localhost/app/css/style.cssurl 被映射为http://localhost/ui/css/style.css.

我尝试使用重写,但没有用。

RewriteEngine on
RewriteRule ^/ui/ /app/
Run Code Online (Sandbox Code Playgroud)

我需要找到更正 URL 的正确方法。任何帮助将不胜感激!提前致谢。

apache mod-rewrite tomcat mod-proxy proxypass

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

标签 统计

apache ×1

file ×1

java ×1

mod-proxy ×1

mod-rewrite ×1

proxypass ×1

text ×1

tomcat ×1