小编Bad*_*ral的帖子

java字符串拆分在除撇号之外的所有非字母数字上

所以我想在任何非字母数字字符上拆分java中的字符串.

目前我一直这样做

words= Str.split("\\W+");
Run Code Online (Sandbox Code Playgroud)

但是我想在那里留下撇号("'").是否有任何正则表达式来保留撇号但是踢掉剩下的垃圾?谢谢.

java regex

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

面板上的画线没有显示出来

我有一个名为panel1的Panel,我正在尝试使用以下代码在我的panel1上画一条线:

var g = panel1.CreateGraphics();
var p = new Pen(Color.Black, 3);

var point1 = new Point(234,118);
var point2 = new Point(293,228);

g.DrawLine(p, point1, point2);
Run Code Online (Sandbox Code Playgroud)

但没有任何东西出现.有任何想法吗?这是一个Windows窗体.

c# graphics winforms

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

使用嵌入式API向节点添加标签

使用Neo4j 2.0里程碑3

目前有此代码(工作代码)

String DB_PATH = "/usr/local/Cellar/neo4j/community-1.8.1-unix/libexec/data/graph.db";
GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(DB_PATH);
Transaction tx = graphDb.beginTx();
try {
   Node myNode = graphDb.createNode();

tx.success();
}
finally {
   tx.finish();
}
Run Code Online (Sandbox Code Playgroud)

这是嵌入式API.如何在节点中添加标签?谢谢!

java neo4j

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

在内存中创建文件并让用户下载

我来自asp.net的剃须刀.通常我会使用[FilePost],但不知道如何在grails中使用它.情况就是这样

我有一个控制器

class MyController{
def index{ }
}
Run Code Online (Sandbox Code Playgroud)

然后我以索引的形式链接索引

<g:link controller="MyController" action="downloadFile">Download</g:link><br>
Run Code Online (Sandbox Code Playgroud)

我想要做的是取一个字符串(无论它是什么),我希望它提示用户下载包含该字符串的文本文件.谢谢!

grails text download

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

logger4j IsTracingEnabled

在IntelliJ中获取此Grails错误,从未见过它.我正在运行Grails 2.2.1

| Error Fatal error during compilation java.lang.NoSuchMethodError: org.apache.log4j.Logger.isTraceEnabled()Z (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.NoSuchMethodError: org.apache.log4j.Logger.isTraceEnabled()Z
at org.slf4j.impl.GrailsLog4jLoggerAdapter.isTraceEnabled(GrailsLog4jLoggerAdapter.java:51)
at org.apache.commons.logging.impl.SLF4JLog.isTraceEnabled(SLF4JLog.java:86)
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:230)
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:242)
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.scan(ClassPathBeanDefinitionScanner.java:220)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrConstructorNewInstance(ReflectiveInterceptor.java:975)
at _GrailsCompile_groovy$_run_closure3_closure8_closure9.doCall(_GrailsCompile_groovy:62)
at _GrailsCompile_groovy$_run_closure3_closure8_closure9.doCall(_GrailsCompile_groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
at _GrailsCompile_groovy.withCompilationErrorHandling(_GrailsCompile_groovy:69)
at _GrailsCompile_groovy.this$4$withCompilationErrorHandling(_GrailsCompile_groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:168)
at _GrailsCompile_groovy$_run_closure3_closure8.doCall(_GrailsCompile_groovy:61)
at _GrailsCompile_groovy$_run_closure3_closure8.doCall(_GrailsCompile_groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at _GrailsCompile_groovy$_run_closure3.doCall(_GrailsCompile_groovy:58)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy) …
Run Code Online (Sandbox Code Playgroud)

java grails trace

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

将历史记录添加到Custom Shell

我正在用Java创建一个自定义shell.我已经添加了历史记录,以便在按下向上箭头时它转到上一个命令,但向上箭头似乎不起作用

这是我的代码:

public class MyShell {

    public static class JavaStringHistory
    {
        private List<String> history = new ArrayList<String>();
    }

    public static void main(String[] args) throws java.io.IOException {
        JavaStringHistory javaStringHistory = new JavaStringHistory();
        javaStringHistory.history.add("");

        Integer indexOfHistory = 0;

        String commandLine;
        BufferedReader console = new BufferedReader
                (new InputStreamReader(System.in));


        //Break with Ctrl+C
        while (true) {
            //read the command
            System.out.print("Shell>");
            commandLine = console.readLine();
            javaStringHistory.history.add(commandLine);

            //if just a return, loop
            if (commandLine.equals(""))
                continue;
            //history

            if (commandLine.equals(KeyEvent.VK_UP))
            {
                System.out.println("up arrow");
            }
            //help command
            if (commandLine.equals("help"))
            {
                System.out.println(); …
Run Code Online (Sandbox Code Playgroud)

java shell

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

Razor MVC3保持全局变量集返回视图

我有一个全局字符串变量,我在一个操作后设置(按下提交按钮),然后我想在我按下另一个按钮时访问相同的字符串,目前我正在做类似的事情

GlobalVariable = "blah";
return View();
Run Code Online (Sandbox Code Playgroud)

再次访问此操作的最佳做​​法是什么?我想指出它是同一页面(index.cshtml)

谢谢!

c# asp.net-mvc

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

如何禁用Windows服务C#的超时?

我有一个运行和启动良好的Windows服务,但是,它运行一个后台线程(其中多个)进行一些严肃的计算.

经过一些挖掘后,我发现它是由于所有Windows服务都有的超时.目前,它从数据库中的表中读取,将其加载到对象中,然后对所述对象进行一些分析.这一切都在OnStart方法中完成,然后调用其他方法.是否有一些技巧可以保持服务运行或任何方式停止超时而无需进入注册表?谢谢

c# windows-services timeout

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

JButton setlocation不起作用

我是Java新手.我正在尝试移动JButton当前居中的位置,因此我将位置更改为静态位置并且它没有移动.任何的想法?

public Main(BufferedImage image) {
    this.image = image;
}

protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    // Draw image centered.
    int x = (getWidth() - image.getWidth())/2;
    int y = 0;//(getHeight() - image.getHeight())/2;
    g.drawImage(image, x, y, this);
}

public static void main(String[] args) throws IOException {
    String path = "img/visualizerLogo3.jpg";
    BufferedImage image = ImageIO.read(new File(path));
    Main contentPane = new Main(image);
    contentPane.setOpaque(true);
    contentPane.setLayout(new GridBagLayout());
    JButton submit = new JButton("Load File");
    submit.setLocation(600, 800);
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setContentPane(contentPane);
    f.setSize(1200,1000);
    //f.setLocation(200,200); …
Run Code Online (Sandbox Code Playgroud)

java swing jframe jbutton layout-manager

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

从Windows运行EXE从传入静态输入

目前我有一个运行的进程,但它需要用户输入

y <return>
<return>
Run Code Online (Sandbox Code Playgroud)

我使用的代码如下

ProcessStartInfo psi = new ProcessStartInfo();
string exepath = Directory.GetParent(System.Reflection.Assembly.GetExecutingAssembly().Location).ToString();
Process proc = new Process();
psi.FileName = exepath + @"\lib\dnaml";
psi.RedirectStandardInput = true;
psi.Arguments = "y\r \r";
psi.UserShellExecute = true;
proc.StartInfo = psi;
proc.Start();
proc.WaitForExit();
Run Code Online (Sandbox Code Playgroud)

我想硬输入这些输入.有什么建议吗?谢谢

c# console-application

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