小编zga*_*r20的帖子

使用IntelliJ IDEA引用带有Java相对路径的文本文件

我有一个从.txt文件中读取数字的程序.我的问题是放置此文件的位置,或者如何使用相对路径引用它,以便在不使用绝对路径的情况下访问此文件.

java text relative-path

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

无法卸载Visual Studio 2015 RC社区

我已经使用visual studio 2015 RC社区了一段时间,我发现我可以从我的大学免费获得完整的企业版.但是,在我从控制面板上卸载了社区版之后,我仍然在我的开始菜单中看到它,它就像没有发生任何事情一样运行.我在网上搜索时看到,使用cmd /uninstall /force但我不知道在C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE目录中使用哪个应用程序来使用它们.

请帮我删除这个IDE,以便我可以重新安装它.

visual-studio visual-studio-2015

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

在Scala中创建并填充2D数组

我刚刚开始研究Scala,我决定做一个roguelike让我的脚湿透.我来自Java背景,我在使用Scala Arrays时遇到了麻烦.

当我尝试制作一个水平,我称之为一个房间时,我想象一个二维阵列#作为墙壁.我尝试使用,据我所知,Scala嵌套for循环#在i ||时放置墙角色 j为0,或者当i ||时 j位于数组的末尾.在for循环的括号内,我有temp(i, j) = '#'一个"Expression of type Char doesn't conform to expected type, Nothing"在我的IDE,IntelliJ中给我错误.

我在下面发布了我的代码,如果你可以帮我格式化和/或正确使用我的数组,那就太好了.

class Room
{
    val room = generate

    def generate: Array[Char] =
    {
        var temp = Array[Char](10, 10)

        for (i: Int <- 0 to temp.length; j: Int <- 0 to temp.length)
        {
            if (i == 0 || j == 0 || i == temp.length-1 || j == temp.length-1)
                temp(i, j) = '#'
        } …
Run Code Online (Sandbox Code Playgroud)

java arrays scala intellij-idea multidimensional-array

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

GoLang中的HTML部分

我刚刚开始使用Go,我想用它创建一个Web应用程序.我现在正在尝试的是以handlebarsjs-esque的方式使用模板.我想将页眉和页脚从主页面中拉出来,这样我就可以将它们注入每个网页.

我当前的设置应该解析主页,页眉和页脚HTML文件并缓存它们.然后我执行我的home.html模板,其中包含Title,header.html文件和footer.html文件页面的字段.

每当我搜索类似的页面时,我只看到javascript页面,所以如果这是一个转发,请告诉我在哪里查看.

编辑: 我已经更新了我的代码,以便从@Minty和@putu的答案中获取提示.我正在尝试读取html文件并将它们存储在数据映射中,同时还将模板添加define到我的模板中.我正在努力挤压一些新的错误,因此该网站目前无法呈现.但是,如果有任何新的提示你可以提供,这将有很大帮助.

server.go

package main

import (
    "html/template"
    "io/ioutil"
    "net/http"
    "regexp"
)

var tPath = "./temps/"
var dPath = "./data/"

var templates = template.Must(template.ParseFiles(tPath+"home.html", dPath+"header.html", dPath+"footer.html"))
var validPath = regexp.MustCompile("^/")

func rootHandler(wr http.ResponseWriter, req *http.Request) {
    title := "home"
    headerFile, headErr := ioutil.ReadFile(dPath + "header.html")
    footerFile, footErr := ioutil.ReadFile(dPath + "footer.html")

    if headErr != nil || footErr != nil {
        http.Error(wr, headErr.Error(), http.StatusInternalServerError)
        http.Error(wr, footErr.Error(), http.StatusInternalServerError)
    }

    data := map[string]interface{}{
        "Title":  title,
        "Header": string(headerFile),
        "Footer": …
Run Code Online (Sandbox Code Playgroud)

html go

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

比较Java中可比较的泛型

我有一个通用二叉树,它会向左边添加更少或者相等的对象,以及比右边更大的对象.我的问题是比较泛型,我知道数据值将是一个对象包装的原语或一个字符串,所以它们是可比较的.但是,我不知道如何在代码中实现它.

代码是正在进行的工作,我知道添加方法还没有正确添加,但我正在努力.谢谢

这是TreeNode:

public class TreeNode<T>
{
    //Instance Variables
    TreeNode leftChild;
    TreeNode rightChild;
    int childCount;
    int depth;
    T data;


    public TreeNode(T data, int parentDepth)
    {
        leftChild = null;
        rightChild = null;
        childCount = 0;
        depth = parentDepth + 1;
        this.data = data;
    }

    public TreeNode(int parentDepth)
    {
        leftChild = null;
        rightChild = null;
        childCount = 0;
        depth = parentDepth + 1;
        data = null;
    }


    public void add(T data)
    {
        if (this.data.compareTo(data) <= 0)
        {
            addLeft(data);
        } else if (this.data.compareTo(data) …
Run Code Online (Sandbox Code Playgroud)

java generics compare comparable

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