小编use*_*310的帖子

Groovy - 主要方法放置

这是我的代码:

class cat {}
class dog {
    static void main(String[] args) {}
}
Run Code Online (Sandbox Code Playgroud)

当编译groovy说我没有主要方法.但是当我摆脱猫类时:

class dog {
    static void main(String[] args) {}
}
Run Code Online (Sandbox Code Playgroud)

它的有效期.我想,只要我在任何类中使用main方法代码都是有效的,但我错了.有人解释为什么当main方法驻留在其中一个类中时,我不能拥有多个类吗?

java groovy class object

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

C#实时显示Process的输出

在C#中,我正在启动第三方应用程序,需要2-3个小时才能完成.我需要Process的输出实时写入控制台.我已经做了研究BeginOutputReadLine(),并RedirectStandardOutput从微软的网站,但我的代码仍然没有工作.

目前我的代码只显示进程完成时的输出.我不知道它出了什么问题.

static void Main(string[] args)
{
  Process process;
  process = new Process();
  process.StartInfo.FileName = "C:\\ffmbc\\ffmbc.exe";
  process.StartInfo.Arguments = "-i \\\\dssp-isi-t\\TMD\\B002C010_130520_R2R7.2398v5.mxf -an -vcodec libx264 -level 4.1 -preset veryslow -tune film -x264opts bluray-compat=1:weightp=0:bframes=3:nal-hrd=vbr:vbv-maxrate=40000:vbv-bufsize=30000:keyint=24:b-pyramid=strict:slices=4:aud=1:colorprim=bt709:transfer=bt709:colormatrix=bt709:sar=1/1:ref=4 -b 30M -bt 30M -threads 0 -pass 1 -y \\\\dss-isi-t\\MTPO_Transfer\\dbay\\B002C010_130520_R2R7.2398v5.mxf.h264";
  process.StartInfo.UseShellExecute = false;
  process.StartInfo.CreateNoWindow = true;
  process.StartInfo.RedirectStandardOutput = true;
  process.OutputDataReceived += new DataReceivedEventHandler(OutputHandler);
  process.StartInfo.RedirectStandardInput = true;
  process.Start();
  process.BeginOutputReadLine();
  process.WaitForExit();
  process.Close();
}

private static void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
{
  string line;
  line = (outLine.Data.ToString());
  Console.WriteLine(line); …
Run Code Online (Sandbox Code Playgroud)

c#

9
推荐指数
2
解决办法
7867
查看次数

DateTime到LocalDate(NodaTime)

我有一个DateTime需要转换为NodaTime LocalDate.可以这样做吗?

我有这个:

 DateTime modifiedDate = File.GetLastWriteTime(file);
Run Code Online (Sandbox Code Playgroud)

我想要这个:

LocalTime modifiedDate = File.GetLastWriteTime(file);
Run Code Online (Sandbox Code Playgroud)

但看起来 NodaTime API无法从中获取日期值GetLastWriteTime.

所以我要么a)将DateTime转换为LocalTime或b)以某种方式使用LocalTime从中获取日期值 GetLastWriteTime

c# datetime localtime nodatime

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

C#通过Process.Exited发送参数

我启动一个process.exited用于发送程序指令的过程,该过程已完成.

它运行正常,但我需要向方法发送一个参数Process_Exited().像这样的东西:

process.exited += Process_Exited(jobnumber);
Run Code Online (Sandbox Code Playgroud)

但这不起作用.这是我的代码:

public void x264_thread(string jobnumber, string x264_argument, string audio_argument)
{
    file = new System.IO.StreamWriter("c:\\output\\current.out");
    mysqlconnect("UPDATE h264_encoder set status = 'running' where jobnumber = '" + jobnumber + "'");
    var proc = new Process();
    proc.StartInfo.FileName = "C:\\ffmbc\\ffmbc.exe";
    proc.StartInfo.Arguments = x264_argument;
    proc.StartInfo.UseShellExecute = false;
    proc.StartInfo.RedirectStandardOutput = true;
    proc.StartInfo.RedirectStandardError = true;
    proc.EnableRaisingEvents = true;
    proc.StartInfo.CreateNoWindow = true;
    proc.ErrorDataReceived += proc_DataReceived;
    proc.OutputDataReceived += proc_DataReceived;
    proc.Exited += process_Exited(JobNumber); //This is where I would like to include …
Run Code Online (Sandbox Code Playgroud)

c#

4
推荐指数
2
解决办法
3170
查看次数

GroovyShell().parse 传递参数

我有一个 groovy 脚本,需要从外部 groovy 脚本解析一个类。我不确定如何传递参数。这是有效的:

我正在运行的 Groovy 脚本使用这一行来解析 external.groovy 中的外部类:

new GroovyShell().parse(new File('External.groovy'))
Run Code Online (Sandbox Code Playgroud)

这是 external.groovy 的样子:

class External {
    public external() {
        println "Hello"
    }
}
Run Code Online (Sandbox Code Playgroud)

有用。

我遇到的问题,我找不到将参数传递给外部方法的方法。这是 external.groovy 的样子:

class External {
    public external(String name) {
        println name
    }
}
Run Code Online (Sandbox Code Playgroud)

如何向正在运行的脚本添加参数:

new GroovyShell().parse(new File('external.groovy')) //need to include the 'Name' parameter to this
Run Code Online (Sandbox Code Playgroud)

groovy groovyshell

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

使用Groovy(gpath)获取XML属性的值

在groovy中使用XmlParser().请参阅以下代码.当name的值是type时,我需要打印answer的值.

   <root>
        <foo name = 'type' answer  = 'car'/>
        <foo name = 'color' answer = 'red'/>
        <foo name = 'size' answer = 'big'/>
    </root>
Run Code Online (Sandbox Code Playgroud)

我需要做这样的事情:

def XML = new XmlParser().parseText(XMLstring)
println XML.root.foo.[where  @name = 'type'].@answer
Run Code Online (Sandbox Code Playgroud)

xml groovy gpath

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

GROOVY RESTClient:找不到请求内容类型的编码器*/*

我正在运行一个休息POST请求,我在编译时收到此错误:

Caught: java.lang.IllegalArgumentException: No encoder found for request content type */*
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7' )
import groovyx.net.http.RESTClient
def client = new RESTClient( 'http://localhost' )
def resp = client.post( path : '/services/adi/validateadimeta/fromfile',body : [ file:'foo' ] )
Run Code Online (Sandbox Code Playgroud)

我不确定它是否响应可能是响应的重编码问题?该*/*有我担心,它甚至没有进行连接.当我在命令行上将其作为CURL命令运行时,它可以正常工作. file是此帖子调用所需的唯一参数.

谢谢

java api rest groovy

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

XSLT if Last节点

这是我的XSLT 1.0代码:

<xsl:for-each select = "segment">
    <xsl:if test ="position() != 1 or position() != last()">
      <notfirstorlast></notfirstorlast>    
     </xsl:if> 
</xsl:for-each>
Run Code Online (Sandbox Code Playgroud)

这应该添加一个<notfirstorlast>元素,在所有<segment>节点中为第一个和最后一个节点exepct.但它不起作用.它将在没有或声明的情况下工作.这个作品:

<xsl:if test ="position() != 1>
Run Code Online (Sandbox Code Playgroud)

我或声明有问题.

xml xslt xslt-1.0

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

标签 统计

groovy ×4

c# ×3

java ×2

xml ×2

api ×1

class ×1

datetime ×1

gpath ×1

groovyshell ×1

localtime ×1

nodatime ×1

object ×1

rest ×1

xslt ×1

xslt-1.0 ×1